@Beta @GwtCompatible public interface Equivalence<T>
identity equivalence
and equals equivalence
.Modifier and Type | Method and Description |
---|---|
boolean |
equivalent(T a,
T b)
Returns
true if the given objects are considered equivalent. |
int |
hash(T t)
Returns a hash code for
object . |
boolean equivalent(@Nullable T a, @Nullable T b)
true
if the given objects are considered equivalent.
The equivalent
method implements an equivalence relation on object references:
x
, including null, equivalent(x, x)
should return true
.
x
and y
, equivalent(x, y) == equivalent(y, x)
.
x
, y
, and z
, if
equivalent(x, y)
returns true
and equivalent(y, z)
returns true
, then equivalent(x, z)
should return true
.
x
and y
, multiple invocations
of equivalent(x, y)
consistently return true
or consistently return false
(provided that neither x
nor y
is modified).
int hash(@Nullable T t)
object
. This function must return the same value for
any two references which are equivalent(T, T)
, and should as often as possible return a
distinct value for references which are not equivalent. It should support null references.