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.SQLDropIndexStatement;
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.visitor.SQLASTVisitor;
23 import hunt.sql.ast.statement.SQLExprTableSource;
24 import hunt.sql.ast.statement.SQLDropStatement;
25 
26 
27 import hunt.collection;
28 
29 public class SQLDropIndexStatement : SQLStatementImpl , SQLDropStatement {
30 
31     private SQLName            indexName;
32     private SQLExprTableSource tableName;
33 
34     private SQLExpr            algorithm;
35     private SQLExpr            lockOption;
36     
37     public this() {
38         
39     }
40     
41     public this(string dbType) {
42         super (dbType);
43     }
44 
45     public SQLName getIndexName() {
46         return indexName;
47     }
48 
49     public void setIndexName(SQLName indexName) {
50         this.indexName = indexName;
51     }
52 
53     public SQLExprTableSource getTableName() {
54         return tableName;
55     }
56 
57     public void setTableName(SQLName tableName) {
58         this.setTableName(new SQLExprTableSource(tableName));
59     }
60 
61     public void setTableName(SQLExprTableSource tableName) {
62         this.tableName = tableName;
63     }
64 
65     public SQLExpr getAlgorithm() {
66         return algorithm;
67     }
68 
69     public void setAlgorithm(SQLExpr x) {
70         if (x !is null) {
71             x.setParent(this);
72         }
73         this.algorithm = x;
74     }
75 
76     public SQLExpr getLockOption() {
77         return lockOption;
78     }
79 
80     public void setLockOption(SQLExpr x) {
81         if (x !is null) {
82             x.setParent(this);
83         }
84         this.lockOption = x;
85     }
86 
87     
88     override  protected void accept0(SQLASTVisitor visitor) {
89         if (visitor.visit(this)) {
90             acceptChild(visitor, indexName);
91             acceptChild(visitor, tableName);
92             acceptChild(visitor, algorithm);
93             acceptChild(visitor, lockOption);
94         }
95         visitor.endVisit(this);
96     }
97 
98     override
99     public List!SQLObject getChildren() {
100         List!SQLObject children = new ArrayList!SQLObject();
101         if (indexName !is null) {
102             children.add(indexName);
103         }
104         if (tableName !is null) {
105             children.add(tableName);
106         }
107         return children;
108     }
109 }