jfinal enjoy 3.5

This commit is contained in:
James 2018-10-06 17:17:13 +08:00
parent b9cc8a58e0
commit 985b02177e

View File

@ -134,11 +134,12 @@ public class Compare extends Expr {
} }
if (leftValue instanceof Comparable && if (leftValue instanceof Comparable &&
rightValue != null &&
leftValue.getClass() == rightValue.getClass()) { leftValue.getClass() == rightValue.getClass()) {
return ((Comparable)leftValue).compareTo((Comparable)rightValue) > 0; return ((Comparable)leftValue).compareTo((Comparable)rightValue) > 0;
} }
return checkType(leftValue, rightValue); return checkComparisonValue(leftValue, rightValue);
} }
@SuppressWarnings({"unchecked", "rawtypes"}) @SuppressWarnings({"unchecked", "rawtypes"})
@ -166,11 +167,12 @@ public class Compare extends Expr {
} }
if (leftValue instanceof Comparable && if (leftValue instanceof Comparable &&
rightValue != null &&
leftValue.getClass() == rightValue.getClass()) { leftValue.getClass() == rightValue.getClass()) {
return ((Comparable)leftValue).compareTo((Comparable)rightValue) >= 0; return ((Comparable)leftValue).compareTo((Comparable)rightValue) >= 0;
} }
return checkType(leftValue, rightValue); return checkComparisonValue(leftValue, rightValue);
} }
@SuppressWarnings({"unchecked", "rawtypes"}) @SuppressWarnings({"unchecked", "rawtypes"})
@ -198,11 +200,12 @@ public class Compare extends Expr {
} }
if (leftValue instanceof Comparable && if (leftValue instanceof Comparable &&
rightValue != null &&
leftValue.getClass() == rightValue.getClass()) { leftValue.getClass() == rightValue.getClass()) {
return ((Comparable)leftValue).compareTo((Comparable)rightValue) < 0; return ((Comparable)leftValue).compareTo((Comparable)rightValue) < 0;
} }
return checkType(leftValue, rightValue); return checkComparisonValue(leftValue, rightValue);
} }
@SuppressWarnings({"unchecked", "rawtypes"}) @SuppressWarnings({"unchecked", "rawtypes"})
@ -230,11 +233,12 @@ public class Compare extends Expr {
} }
if (leftValue instanceof Comparable && if (leftValue instanceof Comparable &&
rightValue != null &&
leftValue.getClass() == rightValue.getClass()) { leftValue.getClass() == rightValue.getClass()) {
return ((Comparable)leftValue).compareTo((Comparable)rightValue) <= 0; return ((Comparable)leftValue).compareTo((Comparable)rightValue) <= 0;
} }
return checkType(leftValue, rightValue); return checkComparisonValue(leftValue, rightValue);
} }
private int getMaxType(Number obj1, Number obj2) { private int getMaxType(Number obj1, Number obj2) {
@ -270,7 +274,7 @@ public class Compare extends Expr {
return ret; return ret;
} }
private Boolean checkType(Object leftValue, Object rightValue) { private Boolean checkComparisonValue(Object leftValue, Object rightValue) {
if (leftValue == null) { if (leftValue == null) {
throw new TemplateException("The operation target on the left side of \"" + op.value() + "\" can not be null", location); throw new TemplateException("The operation target on the left side of \"" + op.value() + "\" can not be null", location);
} }