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.dialect.postgresql.ast.expr.PGPolygonExpr; 17 18 import hunt.sql.ast.SQLExpr; 19 import hunt.sql.ast.SQLObject; 20 import hunt.sql.dialect.postgresql.visitor.PGASTVisitor; 21 import hunt.sql.dialect.postgresql.ast.expr.PGExprImpl; 22 23 24 import hunt.collection; 25 26 27 public class PGPolygonExpr : PGExprImpl { 28 alias accept0 = PGExprImpl.accept0; 29 private SQLExpr value; 30 31 override public PGPolygonExpr clone() { 32 PGPolygonExpr x = new PGPolygonExpr(); 33 if (value !is null) { 34 x.setValue(value.clone()); 35 } 36 return x; 37 } 38 39 public SQLExpr getValue() { 40 return value; 41 } 42 43 public void setValue(SQLExpr value) { 44 this.value = value; 45 } 46 47 override 48 public void accept0(PGASTVisitor visitor) { 49 if (visitor.visit(this)) { 50 acceptChild(visitor, value); 51 } 52 visitor.endVisit(this); 53 } 54 55 override public List!(SQLObject) getChildren() { 56 return Collections.singletonList!(SQLObject)(value); 57 } 58 59 override 60 public size_t toHash() @trusted nothrow { 61 int prime = 31; 62 size_t result = 1; 63 result = prime * result + ((value is null) ? 0 : (cast(Object)value).toHash()); 64 return result; 65 } 66 67 override 68 public bool opEquals(Object obj) { 69 if (this == obj) { 70 return true; 71 } 72 if (obj is null) { 73 return false; 74 } 75 if ( typeid(this) != typeid(obj)) { 76 return false; 77 } 78 PGPolygonExpr other = cast(PGPolygonExpr) obj; 79 if (value is null) { 80 if (other.value !is null) { 81 return false; 82 } 83 } else if (!(cast(Object)(value)).opEquals(cast(Object)(other.value))) { 84 return false; 85 } 86 return true; 87 } 88 89 } 90