This commit is contained in:
@@ -396,8 +396,6 @@ final class FilterBeanNode extends FilterNode {
|
|||||||
if (rs == null) return null;
|
if (rs == null) return null;
|
||||||
if (string && ((CharSequence) rs).length() == 0) return null;
|
if (string && ((CharSequence) rs).length() == 0) return null;
|
||||||
if (number && ((Number) rs).longValue() < this.least) return null;
|
if (number && ((Number) rs).longValue() < this.least) return null;
|
||||||
if (array && Array.getLength(rs) == 0) return null;
|
|
||||||
if (collection && ((Collection) rs).isEmpty()) return null;
|
|
||||||
return rs;
|
return rs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -315,9 +315,9 @@ public class FilterNode {
|
|||||||
}
|
}
|
||||||
} else if (valtype.isArray()) {
|
} else if (valtype.isArray()) {
|
||||||
final int len = Array.getLength(val0);
|
final int len = Array.getLength(val0);
|
||||||
if (len == 0) return null;
|
if (len == 0 && express == NOTIN) return null;
|
||||||
final Class compType = valtype.getComponentType();
|
final Class compType = valtype.getComponentType();
|
||||||
if (atype != compType) {
|
if (atype != compType && len > 0) {
|
||||||
if (!compType.isPrimitive() && Number.class.isAssignableFrom(compType)) throw new RuntimeException("param(" + val0 + ") type not match " + atype + " for column " + column);
|
if (!compType.isPrimitive() && Number.class.isAssignableFrom(compType)) throw new RuntimeException("param(" + val0 + ") type not match " + atype + " for column " + column);
|
||||||
if (atype == int.class || atype == Integer.class) {
|
if (atype == int.class || atype == Integer.class) {
|
||||||
int[] vs = new int[len];
|
int[] vs = new int[len];
|
||||||
@@ -359,38 +359,40 @@ public class FilterNode {
|
|||||||
}
|
}
|
||||||
} else if (val0 instanceof Collection) {
|
} else if (val0 instanceof Collection) {
|
||||||
final Collection collection = (Collection) val0;
|
final Collection collection = (Collection) val0;
|
||||||
if (collection.isEmpty()) return null;
|
if (collection.isEmpty() && express == NOTIN) return null;
|
||||||
Iterator it = collection.iterator();
|
if (!collection.isEmpty()) {
|
||||||
it.hasNext();
|
Iterator it = collection.iterator();
|
||||||
Class fs = it.next().getClass();
|
it.hasNext();
|
||||||
if (Number.class.isAssignableFrom(fs) && atype != fs && atype != class2.get(fs)) { //需要转换
|
Class fs = it.next().getClass();
|
||||||
ArrayList list = new ArrayList(collection.size());
|
if (Number.class.isAssignableFrom(fs) && atype != fs && atype != class2.get(fs)) { //需要转换
|
||||||
if (atype == int.class || atype == Integer.class) {
|
ArrayList list = new ArrayList(collection.size());
|
||||||
for (Number num : (Collection<Number>) collection) {
|
if (atype == int.class || atype == Integer.class) {
|
||||||
list.add(num.intValue());
|
for (Number num : (Collection<Number>) collection) {
|
||||||
}
|
list.add(num.intValue());
|
||||||
} else if (atype == long.class || atype == Long.class) {
|
}
|
||||||
for (Number num : (Collection<Number>) collection) {
|
} else if (atype == long.class || atype == Long.class) {
|
||||||
list.add(num.longValue());
|
for (Number num : (Collection<Number>) collection) {
|
||||||
}
|
list.add(num.longValue());
|
||||||
} else if (atype == short.class || atype == Short.class) {
|
}
|
||||||
for (Number num : (Collection<Number>) collection) {
|
} else if (atype == short.class || atype == Short.class) {
|
||||||
list.add(num.shortValue());
|
for (Number num : (Collection<Number>) collection) {
|
||||||
}
|
list.add(num.shortValue());
|
||||||
} else if (atype == float.class || atype == Float.class) {
|
}
|
||||||
for (Number num : (Collection<Number>) collection) {
|
} else if (atype == float.class || atype == Float.class) {
|
||||||
list.add(num.floatValue());
|
for (Number num : (Collection<Number>) collection) {
|
||||||
}
|
list.add(num.floatValue());
|
||||||
} else if (atype == byte.class || atype == Byte.class) {
|
}
|
||||||
for (Number num : (Collection<Number>) collection) {
|
} else if (atype == byte.class || atype == Byte.class) {
|
||||||
list.add(num.byteValue());
|
for (Number num : (Collection<Number>) collection) {
|
||||||
}
|
list.add(num.byteValue());
|
||||||
} else if (atype == double.class || atype == Double.class) {
|
}
|
||||||
for (Number num : (Collection<Number>) collection) {
|
} else if (atype == double.class || atype == Double.class) {
|
||||||
list.add(num.doubleValue());
|
for (Number num : (Collection<Number>) collection) {
|
||||||
|
list.add(num.doubleValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
val0 = list;
|
||||||
}
|
}
|
||||||
val0 = list;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final Serializable val = val0;
|
final Serializable val = val0;
|
||||||
@@ -573,22 +575,50 @@ public class FilterNode {
|
|||||||
Predicate<T> filter;
|
Predicate<T> filter;
|
||||||
if (val instanceof Collection) {
|
if (val instanceof Collection) {
|
||||||
Collection array = (Collection) val;
|
Collection array = (Collection) val;
|
||||||
filter = new Predicate<T>() {
|
if (array.isEmpty()) { //express 只会是 IN
|
||||||
|
filter = new Predicate<T>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(T t) {
|
public boolean test(T t) {
|
||||||
Object rs = attr.get(t);
|
return false;
|
||||||
return rs != null && array.contains(rs);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return attr.field() + ' ' + express.value() + ' ' + val;
|
return attr.field() + ' ' + express.value() + " []";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
} else {
|
||||||
|
filter = new Predicate<T>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean test(T t) {
|
||||||
|
Object rs = attr.get(t);
|
||||||
|
return rs != null && array.contains(rs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return attr.field() + ' ' + express.value() + ' ' + val;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Class type = val.getClass();
|
Class type = val.getClass();
|
||||||
if (type == int[].class) {
|
if (Array.getLength(val) == 0) {//express 只会是 IN
|
||||||
|
filter = new Predicate<T>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean test(T t) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return attr.field() + ' ' + express.value() + " []";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else if (type == int[].class) {
|
||||||
filter = new Predicate<T>() {
|
filter = new Predicate<T>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -909,7 +939,7 @@ public class FilterNode {
|
|||||||
return sb;
|
return sb;
|
||||||
} else if (value.getClass().isArray()) {
|
} else if (value.getClass().isArray()) {
|
||||||
int len = Array.getLength(value);
|
int len = Array.getLength(value);
|
||||||
if (len == 0) return null;
|
if (len == 0) return express == NOTIN ? null : new StringBuilder("(NULL)");
|
||||||
if (len == 1) {
|
if (len == 1) {
|
||||||
Object firstval = Array.get(value, 0);
|
Object firstval = Array.get(value, 0);
|
||||||
if (firstval != null && firstval.getClass().isArray()) return formatValue(likefit, express, firstval);
|
if (firstval != null && firstval.getClass().isArray()) return formatValue(likefit, express, firstval);
|
||||||
@@ -928,7 +958,7 @@ public class FilterNode {
|
|||||||
return sb.append(')');
|
return sb.append(')');
|
||||||
} else if (value instanceof Collection) {
|
} else if (value instanceof Collection) {
|
||||||
Collection c = (Collection) value;
|
Collection c = (Collection) value;
|
||||||
if (c.isEmpty()) return null;
|
if (c.isEmpty()) return express == NOTIN ? null : new StringBuilder("(NULL)");
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append('(');
|
sb.append('(');
|
||||||
for (Object o : c) {
|
for (Object o : c) {
|
||||||
|
|||||||
Reference in New Issue
Block a user