Package com.google.common.base
Class Equivalence.Wrapper<T>
java.lang.Object
com.google.common.base.Equivalence.Wrapper<T>
- All Implemented Interfaces:
Serializable
- Enclosing class:
Equivalence<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
- Since:
- 10.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Equivalence<? super T> private final Tprivate static final long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturnstrueifEquivalence.equivalent(Object, Object)applied to the wrapped references istrueand both wrappers use thesameequivalence.get()Returns the (possibly null) reference wrapped by this instance.inthashCode()Returns the result ofEquivalence.hash(Object)applied to the wrapped reference.toString()Returns a string representation for this equivalence wrapper.
-
Field Details
-
equivalence
-
reference
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
-
Constructor Details
-
Wrapper
-
-
Method Details
-
get
Returns the (possibly null) reference wrapped by this instance. -
equals
ReturnstrueifEquivalence.equivalent(Object, Object)applied to the wrapped references istrueand both wrappers use thesameequivalence. -
hashCode
public int hashCode()Returns the result ofEquivalence.hash(Object)applied to the wrapped reference. -
toString
Returns a string representation for this equivalence wrapper. The form of this string representation is not specified.
-