|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Defines a total ordering for a set of objects. Its methods allow for the comparison of all objects in the set over which the comparator is defined. It is up to individual implementations to define the set over which they are valid and to reject those objects which they cannot compare by throwing ClassCastExceptions.
Consistency
The implementation should respect the following
consistency constraints:
for each pair of objects a,b such that isComparable(a,b)
compare(a, b) == 0
isEqualTo(a, b)
compare(a, b) < 0
isLessThan(a, b)
!isGreaterThanOrEqualTo(a, b)
compare(a, b) > 0
isGreaterThan(a, b)
!isLessThanOrEqualTo(a, b)
Method Summary | |
int |
compare(Object a,
Object b)
A C-style comparison function that returns a negative value if the first object is less than the second, a positive value if the second object is less, and 0 if the two objects are equal. |
boolean |
isGreaterThan(Object a,
Object b)
Tests the strict order of two objects in the set over which this comparator is defined. |
boolean |
isGreaterThanOrEqualTo(Object a,
Object b)
Tests non-strict order of two objects in the universe over which this comparator is defined. |
boolean |
isLessThan(Object a,
Object b)
Tests the strict order of two objects in the set over which this comparator is defined. |
boolean |
isLessThanOrEqualTo(Object a,
Object b)
Tests non-strict order of two objects in the universe over which this comparator is defined. |
Methods inherited from interface jdsl.core.api.EqualityComparator |
isComparable, isEqualTo |
Method Detail |
public int compare(Object a, Object b) throws ClassCastException
a
- First Object to compareb
- Second Object to compare
ClassCastException
public boolean isGreaterThan(Object a, Object b) throws ClassCastException
a
- First Object to compareb
- Second Object to compare
ClassCastException
- If either object passed in as a parameter
is not a member of the set over which the comparator is defined.public boolean isLessThan(Object a, Object b) throws ClassCastException
a
- First Object to compareb
- Second Object to compare
ClassCastException
- If either object passed in as a parameter
is not a member of the set over which the comparator is defined.public boolean isGreaterThanOrEqualTo(Object a, Object b) throws ClassCastException
a
- First Object to compareb
- Second Object to compare
ClassCastException
- If either object passed in as a parameter
is not a member of the set over which the comparator is defined.public boolean isLessThanOrEqualTo(Object a, Object b) throws ClassCastException
a
- First Object to compareb
- Second Object to compare
ClassCastException
- If either object passed in as a parameter
is not a member of the set over which the comparator is defined.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |