Skip to content

Commit

Permalink
cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
idegtiarenko committed Dec 4, 2024
1 parent ec27e20 commit 1979ba4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ protected Query asQuery(Not not, TranslatorHandler handler) {
}

public static Query doTranslate(Not not, TranslatorHandler handler) {
Query wrappedQuery = handler.asQuery(not.field());
Query q = wrappedQuery.negate(not.source());
return q;
return handler.asQuery(not.field()).negate(not.source());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,8 @@ public static <T> List<T> combine(List<? extends T> left, List<? extends T> righ
}

List<T> list = new ArrayList<>(left.size() + right.size());
if (left.isEmpty() == false) {
list.addAll(left);
}
if (right.isEmpty() == false) {
list.addAll(right);
}
list.addAll(left);
list.addAll(right);
return list;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,41 +112,21 @@ public static DataType fromEs(String name) {
}

public static DataType fromJava(Object value) {
if (value == null) {
return NULL;
}
if (value instanceof Integer) {
return INTEGER;
}
if (value instanceof Long) {
return LONG;
}
if (value instanceof BigInteger) {
return UNSIGNED_LONG;
}
if (value instanceof Boolean) {
return BOOLEAN;
}
if (value instanceof Double) {
return DOUBLE;
}
if (value instanceof Float) {
return FLOAT;
}
if (value instanceof Byte) {
return BYTE;
}
if (value instanceof Short) {
return SHORT;
}
if (value instanceof ZonedDateTime) {
return DATETIME;
}
if (value instanceof String || value instanceof Character) {
return KEYWORD;
}

return null;
return switch (value) {
case null -> NULL;
case Integer i -> INTEGER;
case Long l -> LONG;
case BigInteger bigInteger -> UNSIGNED_LONG;
case Boolean b -> BOOLEAN;
case Double v -> DOUBLE;
case Float v -> FLOAT;
case Byte b -> BYTE;
case Short s -> SHORT;
case ZonedDateTime zonedDateTime -> DATETIME;
case String s -> KEYWORD;
case Character c -> KEYWORD;
default -> null;
};
}

public static boolean isUnsupported(DataType from) {
Expand Down

0 comments on commit 1979ba4

Please sign in to comment.