An implementation of this interface will specify a way to compare two objects from a particular class. This interface is defined in a "generic" way, so all references declared in this interface are of type Object. In an implementation, in order to do any real comparing, all of the paramters below will need to be cast to whatever type that the implementation is expecting.
Notice that it is possible, and in some cases might even be desirable, that an implementation of this interface could be defined to compare objects from one class with objects from a different class (for example, it might be needed to compare a certain String field in an object of one type, with an String field from an object of a different type). So all of the parameters called item1 below could actually be implemented as one type and all of the parameters called item2 could be implemented as a different type.
Method Summary | |
boolean |
isComparable(java.lang.Object item1,
java.lang.Object item2)
This method determines if the two objects are comparable with respect to the specific way this Comparer is implemented. |
boolean |
isEqual(java.lang.Object item1,
java.lang.Object item2)
Determines if the objects are "equal" relative to the way that this Comparator is being implemented. |
boolean |
isGreaterThan(java.lang.Object item1,
java.lang.Object item2)
Determines the order of the objects relative to the way that this Comparator is being implemented. |
boolean |
isGreaterThanOrEqual(java.lang.Object item1,
java.lang.Object item2)
Determines the order of the objects relative to the way that this Comparator is being implemented. |
boolean |
isLessThan(java.lang.Object item1,
java.lang.Object item2)
Determines the order of the objects relative to the way that this Comparator is being implemented. |
boolean |
isLessThanOrEqual(java.lang.Object item1,
java.lang.Object item2)
Determines the order of the objects relative to the way that this Comparator is being implemented. |
Method Detail |
public boolean isComparable(java.lang.Object item1, java.lang.Object item2)
instanceof
operator to check that the types of the two parameters are what is expected by the comparing methods.
public boolean isEqual(java.lang.Object item1, java.lang.Object item2)
public boolean isGreaterThan(java.lang.Object item1, java.lang.Object item2)
public boolean isGreaterThanOrEqual(java.lang.Object item1, java.lang.Object item2)
public boolean isLessThan(java.lang.Object item1, java.lang.Object item2)
public boolean isLessThanOrEqual(java.lang.Object item1, java.lang.Object item2)