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.SQLDeclareStatement;
17 
18 
19 import hunt.collection;
20 
21 import hunt.sql.ast;
22 // import hunt.sql.dialect.sqlserver.ast.SQLServerObjectImpl;
23 // import hunt.sql.dialect.sqlserver.ast.SQLServerStatement;
24 // import hunt.sql.dialect.sqlserver.visitor.SQLServerASTVisitor;
25 import hunt.sql.visitor.SQLASTVisitor;
26 
27 public class SQLDeclareStatement : SQLStatementImpl {
28 
29     protected List!SQLDeclareItem items;
30     
31     public this() {
32         items = new ArrayList!SQLDeclareItem();
33     }
34 
35     public this(SQLName name, SQLDataType dataType) {
36         this.addItem(new SQLDeclareItem(name, dataType));
37     }
38 
39     public this(SQLName name, SQLDataType dataType, SQLExpr value) {
40         this.addItem(new SQLDeclareItem(name, dataType, value));
41     }
42 
43     override
44     public void accept0(SQLASTVisitor visitor) {
45         if (visitor.visit(this)) {
46             this.acceptChild!SQLDeclareItem(visitor, items);
47         }
48         visitor.endVisit(this);
49     }
50 
51     public List!SQLDeclareItem getItems() {
52         return items;
53     }
54 
55     public void addItem(SQLDeclareItem item) {
56         if (item !is null) {
57             item.setParent(this);
58         }
59         this.items.add(item);
60     }
61 }