This commit is contained in:
地平线
2015-08-27 17:17:16 +08:00
parent 41b7aa1335
commit 5bbc324f5d

View File

@@ -218,8 +218,25 @@ public class FilterNode {
return filter; return filter;
} }
protected final <T> Predicate<T> createFilterPredicate(final Attribute<T, Serializable> attr, final Serializable val) { protected final <T> Predicate<T> createFilterPredicate(final Attribute<T, Serializable> attr, Serializable val0) {
if (attr == null) return null; if (attr == null) return null;
final Class atype = attr.type();
if (val0 != null && atype != val0.getClass() && val0 instanceof Number) {
if (atype == short.class || atype == Short.class) {
val0 = ((Number) val0).shortValue();
} else if (atype == long.class || atype == Long.class) {
val0 = ((Number) val0).longValue();
} else if (atype == byte.class || atype == Byte.class) {
val0 = ((Number) val0).byteValue();
} else if (atype == int.class || atype == Integer.class) {
val0 = ((Number) val0).intValue();
} else if (atype == float.class || atype == Float.class) {
val0 = ((Number) val0).floatValue();
} else if (atype == double.class || atype == Double.class) {
val0 = ((Number) val0).doubleValue();
}
}
final Serializable val = val0;
switch (express) { switch (express) {
case EQUAL: return (T t) -> val.equals(attr.get(t)); case EQUAL: return (T t) -> val.equals(attr.get(t));
case NOTEQUAL: return (T t) -> !val.equals(attr.get(t)); case NOTEQUAL: return (T t) -> !val.equals(attr.get(t));