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.SQLCheck;
17 
18 import hunt.sql.ast.SQLExpr;
19 import hunt.sql.visitor.SQLASTVisitor;
20 import hunt.sql.ast.statement.SQLConstraintImpl;
21 import hunt.sql.ast.statement.SQLTableElement;
22 import hunt.sql.ast.statement.SQLTableConstraint;
23 
24 public class SQLCheck : SQLConstraintImpl , SQLTableElement, SQLTableConstraint {
25 
26     alias cloneTo = SQLConstraintImpl.cloneTo;
27     
28     private SQLExpr expr;
29 
30     public this(){
31 
32     }
33 
34     public this(SQLExpr expr){
35         this.setExpr(expr);
36     }
37 
38     public SQLExpr getExpr() {
39         return expr;
40     }
41 
42     public void setExpr(SQLExpr x) {
43         if (x !is null) {
44             x.setParent(this);
45         }
46         this.expr = x;
47     }
48 
49     
50     override  protected void accept0(SQLASTVisitor visitor) {
51         if (visitor.visit(this)) {
52             acceptChild(visitor, this.getName());
53             acceptChild(visitor, this.getExpr());
54         }
55         visitor.endVisit(this);
56     }
57 
58     public void cloneTo(SQLCheck x) {
59         super.cloneTo(x);
60 
61         if (expr !is null) {
62             expr = expr.clone();
63         }
64     }
65 
66     override public SQLCheck clone() {
67         SQLCheck x = new SQLCheck();
68         cloneTo(x);
69         return x;
70     }
71 }