This commit is contained in:
地平线
2015-11-05 15:46:26 +08:00
parent 67816be311
commit cd90512929
2 changed files with 76 additions and 48 deletions

View File

@@ -396,8 +396,6 @@ final class FilterBeanNode extends FilterNode {
if (rs == null) return null;
if (string && ((CharSequence) rs).length() == 0) 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;
}
}

View File

@@ -315,9 +315,9 @@ public class FilterNode {
}
} else if (valtype.isArray()) {
final int len = Array.getLength(val0);
if (len == 0) return null;
if (len == 0 && express == NOTIN) return null;
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 (atype == int.class || atype == Integer.class) {
int[] vs = new int[len];
@@ -359,7 +359,8 @@ public class FilterNode {
}
} else if (val0 instanceof Collection) {
final Collection collection = (Collection) val0;
if (collection.isEmpty()) return null;
if (collection.isEmpty() && express == NOTIN) return null;
if (!collection.isEmpty()) {
Iterator it = collection.iterator();
it.hasNext();
Class fs = it.next().getClass();
@@ -393,6 +394,7 @@ public class FilterNode {
val0 = list;
}
}
}
final Serializable val = val0;
switch (express) {
case EQUAL: return new Predicate<T>() {
@@ -573,6 +575,20 @@ public class FilterNode {
Predicate<T> filter;
if (val instanceof Collection) {
Collection array = (Collection) val;
if (array.isEmpty()) { //express 只会是 IN
filter = new Predicate<T>() {
@Override
public boolean test(T t) {
return false;
}
@Override
public String toString() {
return attr.field() + ' ' + express.value() + " []";
}
};
} else {
filter = new Predicate<T>() {
@Override
@@ -586,9 +602,23 @@ public class FilterNode {
return attr.field() + ' ' + express.value() + ' ' + val;
}
};
}
} else {
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>() {
@Override
@@ -909,7 +939,7 @@ public class FilterNode {
return sb;
} else if (value.getClass().isArray()) {
int len = Array.getLength(value);
if (len == 0) return null;
if (len == 0) return express == NOTIN ? null : new StringBuilder("(NULL)");
if (len == 1) {
Object firstval = Array.get(value, 0);
if (firstval != null && firstval.getClass().isArray()) return formatValue(likefit, express, firstval);
@@ -928,7 +958,7 @@ public class FilterNode {
return sb.append(')');
} else if (value instanceof Collection) {
Collection c = (Collection) value;
if (c.isEmpty()) return null;
if (c.isEmpty()) return express == NOTIN ? null : new StringBuilder("(NULL)");
StringBuilder sb = new StringBuilder();
sb.append('(');
for (Object o : c) {