if (key.contains("fromRange-")) {
// CHECKSTYLE:OFF
String parsedKey = key.substring(10);
// CHECKSTYLE:ON
if (filter instanceof Number) {
NumberPath path = createNumberPath(entityPath, parsedKey, filter);
predicate = and(predicate, path.goe((Number) filter));
} else if (filter instanceof Date) {
DatePath path = entityPath.getDate(parsedKey, Date.class);
predicate = and(predicate, path.goe((Date) filter));
}
} else if (key.contains("toRange-")) {
// CHECKSTYLE:OFF
String parsedKey = key.substring(8);
// CHECKSTYLE:ON
if (filter instanceof Number) {
NumberPath path = createNumberPath(entityPath, parsedKey, filter);
predicate = and(predicate, path.loe((Number) filter));
} else if (filter instanceof Date) {
DatePath path = entityPath.getDate(parsedKey, Date.class);
predicate = and(predicate, path.loe((Date) filter));
}
} else if (key.contains("list-")) {
// CHECKSTYLE:OFF
// if searching elements from list
String parsedKey = key.substring(5);
// CHECKSTYLE:ON
ListPath path = entityPath.getList(parsedKey, filter.getClass());
predicate = and(predicate, path.contains(filter));
} else { // if not ranged search
if (filter instanceof String) {
StringPath path = entityPath.getString(key);
String filterString = (String) filter;
predicate = and(predicate, path.startsWithIgnoreCase(filterString));
} else if (filter instanceof Date) {
DatePath path = entityPath.getDate(key, Date.class);
predicate = and(predicate, path.eq(filter));
} else if (filter instanceof Number) {
NumberPath path = createNumberPath(entityPath, key, filter);
predicate = and(predicate, path.eq(filter));
} else if (filter instanceof Boolean) {
BooleanPath path = entityPath.getBoolean(key);
predicate = and(predicate, path.eq((Boolean) filter));
} else if (filter instanceof Enum) {
EnumPath path = entityPath.getEnum(key, Enum.class);
predicate = and(predicate, path.eq(filter));
} else if (BaseEntity.class.isAssignableFrom(filter.getClass())) {
PathBuilder path = entityPath.get(key);
predicate = and(predicate, path.eq(filter));
}
}
}
}