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.SQLDropSequenceStatement; 17 18 import hunt.sql.ast.SQLName; 19 import hunt.sql.ast.SQLObject; 20 import hunt.sql.ast.SQLStatementImpl; 21 import hunt.sql.ast.expr.SQLPropertyExpr; 22 import hunt.sql.visitor.SQLASTVisitor; 23 import hunt.sql.ast.statement.SQLDropStatement; 24 25 26 import hunt.collection; 27 28 public class SQLDropSequenceStatement : SQLStatementImpl , SQLDropStatement { 29 30 private SQLName name; 31 private bool ifExists; 32 33 public this() { 34 35 } 36 37 public this(string dbType) { 38 super (dbType); 39 } 40 41 42 override protected void accept0(SQLASTVisitor visitor) { 43 if (visitor.visit(this)) { 44 acceptChild(visitor, name); 45 } 46 visitor.endVisit(this); 47 } 48 49 override 50 public List!SQLObject getChildren() { 51 List!SQLObject children = new ArrayList!SQLObject(); 52 if (name !is null) { 53 children.add(name); 54 } 55 return children; 56 } 57 58 public SQLName getName() { 59 return name; 60 } 61 62 public void setName(SQLName name) { 63 this.name = name; 64 } 65 66 public bool isIfExists() { 67 return ifExists; 68 } 69 70 public void setIfExists(bool ifExists) { 71 this.ifExists = ifExists; 72 } 73 74 public string getSchema() { 75 SQLName name = getName(); 76 if (name is null) { 77 return null; 78 } 79 80 if (cast(SQLPropertyExpr)(name) !is null ) { 81 return (cast(SQLPropertyExpr) name).getOwnernName(); 82 } 83 84 return null; 85 } 86 }