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.PGCircleExpr;
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 public class PGCircleExpr : PGExprImpl {
27 alias accept0 = PGExprImpl.accept0;
28 private SQLExpr value;
29
30 override public PGCircleExpr clone() {
31 PGCircleExpr x = new PGCircleExpr();
32 if (value !is null) {
33 x.setValue(value.clone());
34 }
35 return x;
36 }
37
38 public SQLExpr getValue() {
39 return value;
40 }
41
42 public void setValue(SQLExpr value) {
43 this.value = value;
44 }
45
46
47 override public void accept0(PGASTVisitor visitor) {
48 if (visitor.visit(this)) {
49 acceptChild(visitor, value);
50 }
51 visitor.endVisit(this);
52 }
53
54 override
55 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 PGCircleExpr other = cast(PGCircleExpr) 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 }