|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.google.common.base.Equivalence.Wrapper<T>
public static final class Equivalence.Wrapper<T>
Wraps an object so that equals(Object)
and hashCode()
delegate to an
Equivalence
.
For example, given an Equivalence
for strings
named equiv
that tests equivalence using their lengths:
equiv.wrap("a").equals(equiv.wrap("b")) // true
equiv.wrap("a").equals(equiv.wrap("hello")) // false
Note in particular that an equivalence wrapper is never equal to the object it wraps.
equiv.wrap(obj).equals(obj) // always false
Method Summary | |
---|---|
boolean |
equals(Object obj)
Returns true if Equivalence.equivalent(Object, Object) applied to the wrapped
references is true and both wrappers use the same
equivalence. |
T |
get()
Returns the (possibly null) reference wrapped by this instance. |
int |
hashCode()
Returns the result of Equivalence.hash(Object) applied to the the wrapped reference. |
String |
toString()
Returns a string representation for this equivalence wrapper. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
@Nullable public T get()
public boolean equals(@Nullable Object obj)
true
if Equivalence.equivalent(Object, Object)
applied to the wrapped
references is true
and both wrappers use the same
equivalence.
equals
in class Object
public int hashCode()
Equivalence.hash(Object)
applied to the the wrapped reference.
hashCode
in class Object
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |