T - the type of objects that may be compared for equality or order.public interface Equality<T> extends Comparator<T>
A comparator to be used for element equality as well as for ordering. Implementing classes should ensure that:
compare function is consistent with
equals. If two objects compare
to 0 then they are equals and the
the reciprocal is true (this ensures that sorted collections/maps
do not break the general contract of their parent class based on
object equal).hashcode function is consistent with
equals: If two objects are equals, they have
the same hashcode (the reciprocal is not true).null value is supported (even for
comparisons) and the hashcode value of null is 0.Equalities| Modifier and Type | Method and Description |
|---|---|
boolean |
areEqual(T left,
T right)
Indicates if the specified objects can be considered equal.
|
int |
compare(T left,
T right)
Compares the specified objects for order.
|
int |
hashCodeOf(T object)
Returns the hash code for the specified object (consistent with
areEqual(T, T)). |
equalsint hashCodeOf(T object)
areEqual(T, T)). Two objects considered equal have
the same hash code. The hash code of null is always
0.object - the object to return the hashcode for.boolean areEqual(T left, T right)
(compare(o1, o2) == 0) but
usually faster.left - the first object (or null).right - the second object (or null).true if both objects are considered equal;
false otherwise.int compare(T left, T right)
null is supported.compare in interface Comparator<T>left - the first object.right - the second object.Copyright © 2005-2013 Javolution. All Rights Reserved.