|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2017 the original author or authors. |
|
|
|
* Copyright 2002-2019 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -83,20 +83,16 @@ public class StandardTypeComparator implements TypeComparator { |
|
|
|
return leftBigInteger.compareTo(rightBigInteger); |
|
|
|
return leftBigInteger.compareTo(rightBigInteger); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (leftNumber instanceof Long || rightNumber instanceof Long) { |
|
|
|
else if (leftNumber instanceof Long || rightNumber instanceof Long) { |
|
|
|
// Don't call Long.compare here - only available on JDK 1.7+
|
|
|
|
return Long.compare(leftNumber.longValue(), rightNumber.longValue()); |
|
|
|
return compare(leftNumber.longValue(), rightNumber.longValue()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else if (leftNumber instanceof Integer || rightNumber instanceof Integer) { |
|
|
|
else if (leftNumber instanceof Integer || rightNumber instanceof Integer) { |
|
|
|
// Don't call Integer.compare here - only available on JDK 1.7+
|
|
|
|
return Integer.compare(leftNumber.intValue(), rightNumber.intValue()); |
|
|
|
return compare(leftNumber.intValue(), rightNumber.intValue()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else if (leftNumber instanceof Short || rightNumber instanceof Short) { |
|
|
|
else if (leftNumber instanceof Short || rightNumber instanceof Short) { |
|
|
|
// Don't call Short.compare here - only available on JDK 1.7+
|
|
|
|
return leftNumber.shortValue() - rightNumber.shortValue(); |
|
|
|
return compare(leftNumber.shortValue(), rightNumber.shortValue()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else if (leftNumber instanceof Byte || rightNumber instanceof Byte) { |
|
|
|
else if (leftNumber instanceof Byte || rightNumber instanceof Byte) { |
|
|
|
// Don't call Short.compare here - only available on JDK 1.7+
|
|
|
|
return leftNumber.byteValue() - rightNumber.byteValue(); |
|
|
|
return compare(leftNumber.byteValue(), rightNumber.byteValue()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
// Unknown Number subtypes -> best guess is double multiplication
|
|
|
|
// Unknown Number subtypes -> best guess is double multiplication
|
|
|
|
@ -116,21 +112,4 @@ public class StandardTypeComparator implements TypeComparator { |
|
|
|
throw new SpelEvaluationException(SpelMessage.NOT_COMPARABLE, left.getClass(), right.getClass()); |
|
|
|
throw new SpelEvaluationException(SpelMessage.NOT_COMPARABLE, left.getClass(), right.getClass()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static int compare(long x, long y) { |
|
|
|
|
|
|
|
return (x < y ? -1 : (x > y ? 1 : 0)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static int compare(int x, int y) { |
|
|
|
|
|
|
|
return (x < y ? -1 : (x > y ? 1 : 0)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static int compare(short x, short y) { |
|
|
|
|
|
|
|
return x - y; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static int compare(byte x, byte y) { |
|
|
|
|
|
|
|
return x - y; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|