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