1 /* 2 * Copyright 2015-2018 HuntLabs.cn 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 module hunt.sql.ast.statement.SQLCreateSequenceStatement; 17 18 import hunt.sql.ast; 19 import hunt.sql.ast.expr.SQLPropertyExpr; 20 // import hunt.sql.dialect.oracle.visitor.OracleASTVisitor; 21 import hunt.sql.visitor.SQLASTVisitor; 22 import hunt.sql.ast.statement.SQLCreateStatement; 23 24 import hunt.collection; 25 import hunt.Boolean; 26 /** 27 * Created by wenshao on 16/9/14. 28 */ 29 public class SQLCreateSequenceStatement : SQLStatementImpl , SQLCreateStatement { 30 private SQLName name; 31 32 private SQLExpr startWith; 33 private SQLExpr incrementBy; 34 private SQLExpr minValue; 35 private SQLExpr maxValue; 36 private bool noMaxValue; 37 private bool noMinValue; 38 39 private Boolean cycle; 40 private Boolean cache; 41 private SQLExpr cacheValue; 42 43 private Boolean order; 44 45 override 46 public void accept0(SQLASTVisitor visitor) { 47 if (visitor.visit(this)) { 48 acceptChild(visitor, name); 49 acceptChild(visitor, startWith); 50 acceptChild(visitor, incrementBy); 51 acceptChild(visitor, minValue); 52 acceptChild(visitor, maxValue); 53 } 54 visitor.endVisit(this); 55 } 56 57 override 58 public List!SQLObject getChildren() { 59 List!SQLObject children = new ArrayList!SQLObject(); 60 if (name !is null) { 61 children.add(name); 62 } 63 if (startWith !is null) { 64 children.add(startWith); 65 } 66 if (incrementBy !is null) { 67 children.add(incrementBy); 68 } 69 if (minValue !is null) { 70 children.add(minValue); 71 } 72 if (maxValue !is null) { 73 children.add(maxValue); 74 } 75 return children; 76 } 77 78 public SQLName getName() { 79 return name; 80 } 81 82 public void setName(SQLName name) { 83 this.name = name; 84 } 85 86 public SQLExpr getStartWith() { 87 return startWith; 88 } 89 90 public void setStartWith(SQLExpr startWith) { 91 this.startWith = startWith; 92 } 93 94 public SQLExpr getIncrementBy() { 95 return incrementBy; 96 } 97 98 public void setIncrementBy(SQLExpr incrementBy) { 99 this.incrementBy = incrementBy; 100 } 101 102 public SQLExpr getMaxValue() { 103 return maxValue; 104 } 105 106 public void setMaxValue(SQLExpr maxValue) { 107 this.maxValue = maxValue; 108 } 109 110 public Boolean getCycle() { 111 return cycle; 112 } 113 114 public void setCycle(Boolean cycle) { 115 this.cycle = cycle; 116 } 117 118 public Boolean getCache() { 119 return cache; 120 } 121 122 public void setCache(Boolean cache) { 123 this.cache = cache; 124 } 125 126 public Boolean getOrder() { 127 return order; 128 } 129 130 public void setOrder(Boolean order) { 131 this.order = order; 132 } 133 134 public SQLExpr getMinValue() { 135 return minValue; 136 } 137 138 public void setMinValue(SQLExpr minValue) { 139 this.minValue = minValue; 140 } 141 142 public bool isNoMaxValue() { 143 return noMaxValue; 144 } 145 146 public void setNoMaxValue(bool noMaxValue) { 147 this.noMaxValue = noMaxValue; 148 } 149 150 public bool isNoMinValue() { 151 return noMinValue; 152 } 153 154 public void setNoMinValue(bool noMinValue) { 155 this.noMinValue = noMinValue; 156 } 157 158 public string getSchema() { 159 SQLName name = getName(); 160 if (name is null) { 161 return null; 162 } 163 164 if (cast(SQLPropertyExpr)(name) !is null ) { 165 return (cast(SQLPropertyExpr) name).getOwnernName(); 166 } 167 168 return null; 169 } 170 171 public SQLExpr getCacheValue() { 172 return cacheValue; 173 } 174 175 public void setCacheValue(SQLExpr cacheValue) { 176 if (cacheValue !is null) { 177 cacheValue.setParent(this); 178 } 179 this.cacheValue = cacheValue; 180 } 181 }