Skip to content

Commit df7c792

Browse files
feat: syntax sugar
Signed-off-by: Andreas Reichel <andreas@manticore-projects.com>
1 parent 67bfae6 commit df7c792

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

src/main/java/net/sf/jsqlparser/expression/CastExpression.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ public static DataType from(String typeStr) {
208208
}
209209
}
210210

211+
public boolean isOf(CastExpression anotherCast) {
212+
return this.colDataType.equals(anotherCast.colDataType);
213+
}
214+
211215
public static boolean isOf(ColDataType colDataType, DataType... types) {
212216
return Set.of(types).contains(DataType.from(colDataType.getDataType()));
213217
}

src/main/java/net/sf/jsqlparser/statement/create/table/ColDataType.java

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,17 @@
99
*/
1010
package net.sf.jsqlparser.statement.create.table;
1111

12+
import net.sf.jsqlparser.statement.select.PlainSelect;
13+
1214
import java.io.Serializable;
1315
import java.util.ArrayList;
1416
import java.util.Collection;
1517
import java.util.Collections;
1618
import java.util.List;
19+
import java.util.Objects;
1720
import java.util.Optional;
21+
1822
import static java.util.stream.Collectors.joining;
19-
import net.sf.jsqlparser.statement.select.PlainSelect;
2023

2124
public class ColDataType implements Serializable {
2225

@@ -144,4 +147,29 @@ public ColDataType addArrayData(Collection<Integer> arrayData) {
144147
collection.addAll(arrayData);
145148
return this.withArrayData(collection);
146149
}
150+
151+
@Override
152+
public final boolean equals(Object o) {
153+
if (this == o) {
154+
return true;
155+
}
156+
if (!(o instanceof ColDataType)) {
157+
return false;
158+
}
159+
160+
ColDataType that = (ColDataType) o;
161+
return dataType.equalsIgnoreCase(that.dataType)
162+
&& Objects.equals(argumentsStringList, that.argumentsStringList)
163+
&& Objects.equals(characterSet, that.characterSet)
164+
&& Objects.equals(arrayData, that.arrayData);
165+
}
166+
167+
@Override
168+
public int hashCode() {
169+
int result = dataType.hashCode();
170+
result = 31 * result + Objects.hashCode(argumentsStringList);
171+
result = 31 * result + Objects.hashCode(characterSet);
172+
result = 31 * result + Objects.hashCode(arrayData);
173+
return result;
174+
}
147175
}

0 commit comments

Comments
 (0)