Package org.springframework.expression
Interface TypeComparator
- All Known Implementing Classes:
StandardTypeComparator
public interface TypeComparator
Instances of a type comparator should be able to compare pairs of objects for equality. The specification of the return value is the same as forComparable
.- Since:
- 3.0
- Author:
- Andy Clement
- See Also:
Comparable
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
canCompare(Object firstObject, Object secondObject)
Returntrue
if the comparator can compare these two objects.int
compare(Object firstObject, Object secondObject)
Compare two given objects.
Method Detail
canCompare
boolean canCompare(@Nullable Object firstObject, @Nullable Object secondObject)
Returntrue
if the comparator can compare these two objects.- Parameters:
firstObject
- the first objectsecondObject
- the second object- Returns:
true
if the comparator can compare these objects
compare
int compare(@Nullable Object firstObject, @Nullable Object secondObject) throws EvaluationException
Compare two given objects.- Parameters:
firstObject
- the first objectsecondObject
- the second object- Returns:
- 0 if they are equal, <0 if the first is smaller than the second, or>0 if the first is larger than the second
- Throws:
EvaluationException
- if a problem occurs during comparison (or if they are not comparable in the first place)