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.SQLAlterTableAddColumn;
17 
18 import hunt.collection;
19 
20 import hunt.sql.ast.SQLName;
21 import hunt.sql.ast.SQLObjectImpl;
22 import hunt.sql.visitor.SQLASTVisitor;
23 import hunt.sql.ast.statement.SQLAlterStatement;
24 import hunt.sql.ast.statement.SQLAlterTableItem;
25 import hunt.sql.ast.statement.SQLColumnDefinition;
26 import hunt.sql.ast.SQLObject;
27 
28 public class SQLAlterTableAddColumn : SQLObjectImpl , SQLAlterTableItem {
29 
30     private  List!SQLColumnDefinition columns;
31     
32     
33     // for mysql
34     private SQLName firstColumn;
35     private SQLName afterColumn;
36 
37     private bool first;
38 
39     this()
40     {
41         columns = new ArrayList!SQLColumnDefinition();
42     }
43 
44     override  protected void accept0(SQLASTVisitor visitor) {
45         if (visitor.visit(this)) {
46             acceptChild!SQLColumnDefinition(visitor, columns);
47         }
48         visitor.endVisit(this);
49     }
50 
51     public List!SQLColumnDefinition getColumns() {
52         return columns;
53     }
54     
55     public void addColumn(SQLColumnDefinition column) {
56         if (column !is null) {
57             column.setParent(this);
58         }
59         this.columns.add(column);
60     }
61 
62     public SQLName getFirstColumn() {
63         return firstColumn;
64     }
65 
66     public void setFirstColumn(SQLName first) {
67         this.firstColumn = first;
68     }
69 
70     public bool isFirst() {
71         return first;
72     }
73 
74     public void setFirst(bool first) {
75         this.first = first;
76     }
77 
78     public SQLName getAfterColumn() {
79         return afterColumn;
80     }
81 
82     public void setAfterColumn(SQLName after) {
83         this.afterColumn = after;
84     }
85 }