|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
@Beta public interface Equivalence<T>
A strategy for determining whether two instances are considered equivalent. Examples of
equivalences are the identity equivalence
and equals equivalence
.
Method Summary | |
---|---|
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 . |
Method Detail |
---|
boolean equivalent(T a, T b)
true
if the given objects are considered equivalent.
The equivalent
method implements an equivalence relation on non-null object
references:
x
, x.equals(x)
should return true
.
x
and y
, x.equals(y)
should return true
if and only if y.equals(x)
returns true
.
x
, y
, and z
, if x.equals(y)
returns true
and y.equals(z)
returns true
, then x.equals(z)
should return true
.
x
and y
,
multiple invocations of x.equals(y)
consistently return true
or
consistently return false
, provided no information used in equals
comparisons on the objects is modified.
x
, x.equals(null)
should return false
.
int hash(T t)
object
. This function must return the same value for
any two instances which are equivalent(T, T)
, and should as often as possible return a
distinct value for instances which are not equivalent.
NullPointerException
- if t is nullthe same contractual obligations apply here
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |