1 module hunt.sql.ast.SQLMapDataType;
2 
3 import hunt.sql.ast.SQLDataType;
4 import hunt.sql.ast.SQLObjectImpl;
5 import hunt.sql.ast.SQLExpr;
6 import hunt.sql.visitor.SQLASTVisitor;
7 import hunt.sql.util.FnvHash;
8 import hunt.sql.ast.SQLObject;
9 
10 import hunt.Boolean;
11 import hunt.collection;
12 
13 public class SQLMapDataType : SQLObjectImpl , SQLDataType {
14     private string dbType;
15     private SQLDataType keyType;
16     private SQLDataType valueType;
17 
18     public this() {
19 
20     }
21 
22     public this(SQLDataType keyType, SQLDataType valueType) {
23         this.setKeyType(keyType);
24         this.setValueType(valueType);
25     }
26 
27     public this(SQLDataType keyType, SQLDataType valueType, string dbType) {
28         this.setKeyType(keyType);
29         this.setValueType(valueType);
30         this.dbType = dbType;
31     }
32 
33     public override string getName() {
34         return "MAP";
35     }
36 
37     public override long nameHashCode64() {
38         return FnvHash.Constants.MAP;
39     }
40 
41     public override void setName(string name) {
42         throw new Exception("UnsupportedOperation");
43     }
44 
45     public override List!SQLExpr getArguments() {
46         return Collections.emptyList!(SQLExpr)();
47     }
48 
49     
50     public override Boolean getWithTimeZone() {
51         return Boolean.FALSE;
52     }
53 
54     public override void setWithTimeZone(Boolean value) {
55         throw new Exception("UnsupportedOperation");
56     }
57 
58     public override bool isWithLocalTimeZone() {
59         return false;
60     }
61 
62     public override void setWithLocalTimeZone(bool value) {
63         throw new Exception("UnsupportedOperation");
64     }
65 
66     public override void setDbType(string dbType) {
67         dbType = dbType;
68     }
69 
70     public override string getDbType() {
71         return dbType;
72     }
73 
74     protected override void accept0(SQLASTVisitor visitor) {
75         if (visitor.visit(this)) {
76             acceptChild(visitor, keyType);
77             acceptChild(visitor, valueType);
78         }
79         visitor.endVisit(this);
80     }
81 
82     public override SQLMapDataType clone() {
83         SQLMapDataType x = new SQLMapDataType();
84         x.dbType = dbType;
85 
86         if (keyType !is null) {
87             x.setKeyType(keyType.clone());
88         }
89 
90         if (valueType !is null) {
91             x.setValueType(valueType.clone());
92         }
93 
94         return x;
95     }
96 
97     public SQLDataType getKeyType() {
98         return keyType;
99     }
100 
101     public void setKeyType(SQLDataType x) {
102         if (x !is null) {
103             x.setParent(this);
104         }
105         this.keyType = x;
106     }
107 
108     public SQLDataType getValueType() {
109         return valueType;
110     }
111 
112     public void setValueType(SQLDataType x) {
113         if (x !is null) {
114             x.setParent(this);
115         }
116         this.valueType = x;
117     }
118 }