Polishing

This commit is contained in:
Juergen Hoeller
2019-06-11 23:50:29 +02:00
parent 22aba8bf60
commit 33b5bc2aae
8 changed files with 60 additions and 54 deletions

View File

@@ -26,8 +26,8 @@ import org.springframework.lang.Nullable;
import org.springframework.util.NumberUtils;
/**
* A simple basic {@link TypeComparator} implementation.
* It supports comparison of Numbers and types implementing Comparable.
* A basic {@link TypeComparator} implementation: supports comparison of
* {@link Number} types as well as types implementing {@link Comparable}.
*
* @author Andy Clement
* @author Juergen Hoeller
@@ -89,10 +89,10 @@ public class StandardTypeComparator implements TypeComparator {
return Integer.compare(leftNumber.intValue(), rightNumber.intValue());
}
else if (leftNumber instanceof Short || rightNumber instanceof Short) {
return leftNumber.shortValue() - rightNumber.shortValue();
return Short.compare(leftNumber.shortValue(), rightNumber.shortValue());
}
else if (leftNumber instanceof Byte || rightNumber instanceof Byte) {
return leftNumber.byteValue() - rightNumber.byteValue();
return Byte.compare(leftNumber.byteValue(), rightNumber.byteValue());
}
else {
// Unknown Number subtypes -> best guess is double multiplication