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.SQLAlterTableAddPartition;
17 
18 import hunt.collection;
19 
20 import hunt.sql.ast.SQLExpr;
21 import hunt.sql.ast.SQLObject;
22 import hunt.sql.ast.SQLObjectImpl;
23 import hunt.sql.visitor.SQLASTVisitor;
24 import hunt.sql.ast.statement.SQLAlterTableItem;
25 
26 
27 public class SQLAlterTableAddPartition : SQLObjectImpl , SQLAlterTableItem {
28 
29     private bool               ifNotExists = false;
30 
31     private  List!SQLObject partitions;
32 
33     private SQLExpr               partitionCount;
34     this()
35     {
36         partitions  = new ArrayList!SQLObject(4);
37     }
38 
39     public List!SQLObject getPartitions() {
40         return partitions;
41     }
42 
43     public void addPartition(SQLObject partition) {
44         if (partition !is null) {
45             partition.setParent(this);
46         }
47         this.partitions.add(partition);
48     }
49 
50     public bool isIfNotExists() {
51         return ifNotExists;
52     }
53 
54     public void setIfNotExists(bool ifNotExists) {
55         this.ifNotExists = ifNotExists;
56     }
57 
58     public SQLExpr getPartitionCount() {
59         return partitionCount;
60     }
61 
62     public void setPartitionCount(SQLExpr partitionCount) {
63         if (partitionCount !is null) {
64             partitionCount.setParent(this);
65         }
66         this.partitionCount = partitionCount;
67     }
68 
69     override  protected void accept0(SQLASTVisitor visitor) {
70         if (visitor.visit(this)) {
71             acceptChild(visitor, partitions);
72         }
73         visitor.endVisit(this);
74     }
75 }