![JAR search and dependency download from the Maven repository](/logo.png)
javadoc.com.google.common.base.Equivalence.Wrapper.html Maven / Gradle / Ivy
The newest version!
Equivalence.Wrapper (Guava: Google Core Libraries for Java 11.0.1 API)
Overview
Package
Class
Use
Tree
Deprecated
Index
Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
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>
@Beta
public static final class Equivalence.Wrapper<T>
- extends Object
- implements Serializable
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:
- Serialized Form
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 |
---|
get
@Nullable public T get()
- Returns the (possibly null) reference wrapped by this instance.
equals
public boolean equals(@Nullable Object obj)
- Returns
true
ifEquivalence.equivalent(Object, Object)
applied to the wrapped references istrue
and both wrappers use thesame
equivalence.
hashCode
public int hashCode()
- Returns the result of
Equivalence.hash(Object)
applied to the the wrapped reference.
toString
public String toString()
- Returns a string representation for this equivalence wrapper. The form of this string
representation is not specified.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2010-2012. All Rights Reserved.
© 2015 - 2025 Weber Informatics LLC | Privacy Policy