-
Notifications
You must be signed in to change notification settings - Fork 866
/
OAlterClassStatement.java
190 lines (174 loc) · 6.55 KB
/
OAlterClassStatement.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/* Generated By:JJTree: Do not edit this line. OAlterClassStatement.java Version 4.3 */
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=O,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
package com.orientechnologies.orient.core.sql.parser;
import com.orientechnologies.orient.core.metadata.schema.OClass;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class OAlterClassStatement extends OStatement {
/**
* the name of the class
*/
protected OIdentifier name;
/**
* the class property to be altered
*/
public OClass.ATTRIBUTES property;
protected OIdentifier identifierValue;
protected List<OIdentifier> identifierListValue;
protected Boolean add;
protected Boolean remove;
protected ONumber numberValue;
protected Boolean booleanValue;
public OIdentifier customKey;
public OExpression customValue;
// only to manage 'round-robin' as a cluster selection strategy (not a valid identifier)
protected String customString;
protected boolean unsafe;
public OAlterClassStatement(int id) {
super(id);
}
public OAlterClassStatement(OrientSql p, int id) {
super(p, id);
}
@Override public void toString(Map<Object, Object> params, StringBuilder builder) {
builder.append("ALTER CLASS ");
name.toString(params, builder);
builder.append(" " + property.name() + " ");
switch (property) {
case NAME:
case SHORTNAME:
case ADDCLUSTER:
case REMOVECLUSTER:
case DESCRIPTION:
case ENCRYPTION:
if (numberValue != null) {
numberValue.toString(params, builder);//clusters only
} else if (identifierValue != null) {
identifierValue.toString(params, builder);
} else {
builder.append("null");
}
break;
case CLUSTERSELECTION:
if (identifierValue != null) {
identifierValue.toString(params, builder);
} else if (customString != null) {
builder.append('\'').append(customString).append('\'');
} else {
builder.append("null");
}
break;
case SUPERCLASS:
if (Boolean.TRUE.equals(add)) {
builder.append("+");
} else if (Boolean.TRUE.equals(remove)) {
builder.append("-");
}
if (identifierValue == null) {
builder.append("null");
} else {
identifierValue.toString(params, builder);
}
break;
case SUPERCLASSES:
if (identifierListValue == null) {
builder.append("null");
} else {
boolean first = true;
for (OIdentifier ident : identifierListValue) {
if (!first) {
builder.append(", ");
}
ident.toString(params, builder);
first = false;
}
}
break;
case OVERSIZE:
numberValue.toString(params, builder);
break;
case STRICTMODE:
case ABSTRACT:
builder.append(booleanValue.booleanValue());
break;
case CUSTOM:
customKey.toString(params, builder);
builder.append("=");
if (customValue == null) {
builder.append("null");
} else {
customValue.toString(params, builder);
}
break;
}
if (unsafe) {
builder.append(" UNSAFE");
}
}
public OStatement copy() {
OAlterClassStatement result = new OAlterClassStatement(-1);
result.name = name == null ? null : name.copy();
result.property = property;
result.identifierValue = identifierValue == null ? null : identifierValue.copy();
result.identifierListValue =
identifierListValue == null ? null : identifierListValue.stream().map(x -> x.copy()).collect(Collectors.toList());
result.add = add;
result.remove = remove;
result.numberValue = numberValue == null ? null : numberValue.copy();
result.booleanValue = booleanValue;
result.customKey = customKey == null ? null : customKey.copy();
result.customValue = customValue == null ? null : customValue.copy();
result.customString = customString;
result.unsafe = unsafe;
return result;
}
@Override public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
OAlterClassStatement that = (OAlterClassStatement) o;
if (unsafe != that.unsafe)
return false;
if (name != null ? !name.equals(that.name) : that.name != null)
return false;
if (property != that.property)
return false;
if (identifierValue != null ? !identifierValue.equals(that.identifierValue) : that.identifierValue != null)
return false;
if (identifierListValue != null ? !identifierListValue.equals(that.identifierListValue) : that.identifierListValue != null)
return false;
if (add != null ? !add.equals(that.add) : that.add != null)
return false;
if (remove != null ? !remove.equals(that.remove) : that.remove != null)
return false;
if (numberValue != null ? !numberValue.equals(that.numberValue) : that.numberValue != null)
return false;
if (booleanValue != null ? !booleanValue.equals(that.booleanValue) : that.booleanValue != null)
return false;
if (customKey != null ? !customKey.equals(that.customKey) : that.customKey != null)
return false;
if (customValue != null ? !customValue.equals(that.customValue) : that.customValue != null)
return false;
if (customString != null ? !customString.equals(that.customString) : that.customString != null)
return false;
return true;
}
@Override public int hashCode() {
int result = name != null ? name.hashCode() : 0;
result = 31 * result + (property != null ? property.hashCode() : 0);
result = 31 * result + (identifierValue != null ? identifierValue.hashCode() : 0);
result = 31 * result + (identifierListValue != null ? identifierListValue.hashCode() : 0);
result = 31 * result + (add != null ? add.hashCode() : 0);
result = 31 * result + (remove != null ? remove.hashCode() : 0);
result = 31 * result + (numberValue != null ? numberValue.hashCode() : 0);
result = 31 * result + (booleanValue != null ? booleanValue.hashCode() : 0);
result = 31 * result + (customKey != null ? customKey.hashCode() : 0);
result = 31 * result + (customValue != null ? customValue.hashCode() : 0);
result = 31 * result + (customString != null ? customString.hashCode() : 0);
result = 31 * result + (unsafe ? 1 : 0);
return result;
}
}
/* JavaCC - OriginalChecksum=4668bb1cd336844052df941f39bdb634 (do not edit this line) */