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.stmt.PGValuesQuery;
17 
18 
19 import hunt.collection;
20 
21 import hunt.sql.ast.SQLExpr;
22 import hunt.sql.ast.statement.SQLSelectQuery;
23 import hunt.sql.dialect.postgresql.ast.PGSQLObjectImpl;
24 import hunt.sql.dialect.postgresql.visitor.PGASTVisitor;
25 import hunt.sql.ast.SQLObject;
26 
27 public class PGValuesQuery : PGSQLObjectImpl , SQLSelectQuery {
28 
29     alias accept0 = PGSQLObjectImpl.accept0;
30     
31     private bool          bracket  = false;
32 
33     private List!(SQLExpr) values;
34     
35     this()
36     {
37         values = new ArrayList!(SQLExpr)();
38     }
39 
40     public List!(SQLExpr) getValues() {
41         return values;
42     }
43 
44     override
45     public void accept0(PGASTVisitor visitor) {
46         if (visitor.visit(this)) {
47             acceptChild!SQLExpr(visitor, values);
48         }
49         visitor.endVisit(this);
50     }
51 
52     override
53     public bool isBracket() {
54         return bracket;
55     }
56 
57     override
58     public void setBracket(bool bracket) {
59         this.bracket = bracket;
60     }
61 
62     override public PGValuesQuery clone() {
63         PGValuesQuery x = new PGValuesQuery();
64         x.bracket = bracket;
65 
66         for (int i = 0; i < values.size(); ++i) {
67             SQLExpr value = values.get(i).clone();
68             value.setParent(x);
69             x.values.add(value);
70         }
71 
72         return x;
73     }
74 }