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.SQLAlterSequenceStatement;
17 
18 import hunt.sql.ast.SQLExpr;
19 import hunt.sql.ast.SQLName;
20 import hunt.sql.ast.SQLObject;
21 import hunt.sql.ast.SQLStatementImpl;
22 import hunt.sql.ast.expr.SQLPropertyExpr;
23 import hunt.sql.visitor.SQLASTVisitor;
24 import hunt.sql.ast.statement.SQLAlterStatement;
25 import hunt.Boolean;
26 import hunt.collection;
27 
28 public class SQLAlterSequenceStatement : SQLStatementImpl , SQLAlterStatement {
29     private SQLName name;
30 
31     private SQLExpr startWith;
32     private SQLExpr incrementBy;
33     private SQLExpr minValue;
34     private SQLExpr maxValue;
35     private bool noMaxValue;
36     private bool noMinValue;
37 
38     private Boolean cycle;
39     private Boolean cache;
40     private SQLExpr cacheValue;
41 
42     private Boolean order;
43 
44     override
45     public void accept0(SQLASTVisitor visitor) {
46         if (visitor.visit(this)) {
47             acceptChild(visitor, name);
48             acceptChild(visitor, startWith);
49             acceptChild(visitor, incrementBy);
50             acceptChild(visitor, minValue);
51             acceptChild(visitor, maxValue);
52         }
53         visitor.endVisit(this);
54     }
55 
56     override
57     public List!SQLObject getChildren() {
58         List!SQLObject children = new ArrayList!SQLObject();
59         if (name !is null) {
60             children.add(name);
61         }
62         if (startWith !is null) {
63             children.add(startWith);
64         }
65         if (incrementBy !is null) {
66             children.add(incrementBy);
67         }
68         if (minValue !is null) {
69             children.add(minValue);
70         }
71         if (maxValue !is null) {
72             children.add(maxValue);
73         }
74         return children;
75     }
76 
77     public SQLName getName() {
78         return name;
79     }
80 
81     public void setName(SQLName name) {
82         this.name = name;
83     }
84 
85     public SQLExpr getStartWith() {
86         return startWith;
87     }
88 
89     public void setStartWith(SQLExpr startWith) {
90         this.startWith = startWith;
91     }
92 
93     public SQLExpr getIncrementBy() {
94         return incrementBy;
95     }
96 
97     public void setIncrementBy(SQLExpr incrementBy) {
98         this.incrementBy = incrementBy;
99     }
100 
101     public SQLExpr getMaxValue() {
102         return maxValue;
103     }
104 
105     public void setMaxValue(SQLExpr maxValue) {
106         this.maxValue = maxValue;
107     }
108 
109     public Boolean getCycle() {
110         return cycle;
111     }
112 
113     public void setCycle(Boolean cycle) {
114         this.cycle = cycle;
115     }
116 
117     public Boolean getCache() {
118         return cache;
119     }
120 
121     public void setCache(Boolean cache) {
122         this.cache = cache;
123     }
124 
125     public Boolean getOrder() {
126         return order;
127     }
128 
129     public void setOrder(Boolean order) {
130         this.order = order;
131     }
132 
133     public SQLExpr getMinValue() {
134         return minValue;
135     }
136 
137     public void setMinValue(SQLExpr minValue) {
138         this.minValue = minValue;
139     }
140 
141     public bool isNoMaxValue() {
142         return noMaxValue;
143     }
144 
145     public void setNoMaxValue(bool noMaxValue) {
146         this.noMaxValue = noMaxValue;
147     }
148 
149     public bool isNoMinValue() {
150         return noMinValue;
151     }
152 
153     public void setNoMinValue(bool noMinValue) {
154         this.noMinValue = noMinValue;
155     }
156 
157     public string getSchema() {
158         SQLName name = getName();
159         if (name is null) {
160             return null;
161         }
162 
163         if ( cast(SQLPropertyExpr)name !is null) {
164             return (cast(SQLPropertyExpr) name).getOwnernName();
165         }
166 
167         return null;
168     }
169 
170     public SQLExpr getCacheValue() {
171         return cacheValue;
172     }
173 
174     public void setCacheValue(SQLExpr cacheValue) {
175         if (cacheValue !is null) {
176             cacheValue.setParent(this);
177         }
178         this.cacheValue = cacheValue;
179     }
180 }