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:
comparefunction is consistent with
equals. If two objects
0then they are
equalsand 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).
hashcodefunction is consistent with
equals: If two objects are equals, they have the same hashcode (the reciprocal is not true).
nullvalue is supported (even for
comparisons) and the
|Modifier and Type||Method and Description|
Indicates if the specified objects can be considered equal.
Compares the specified objects for order.
Returns the hash code for the specified object (consistent with
int hashCodeOf(T object)
areEqual(T, T)). Two objects considered
equalhave the same hash code. The hash code of
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
right- the second object (or
trueif both objects are considered equal;
int compare(T left, T right)
left- the first object.
right- the second object.
Copyright © 2005-2013 Javolution. All Rights Reserved.