Class Equivalence.Wrapper<T>

java.lang.Object
org.docx4j.com.google.common.base.Equivalence.Wrapper<T>
All Implemented Interfaces:
java.io.Serializable
Enclosing class:
Equivalence<T>

public static final class Equivalence.Wrapper<T>
extends java.lang.Object
implements java.io.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

    Modifier and Type Method Description
    boolean equals​(@Nullable java.lang.Object obj)
    Returns true if Equivalence.equivalent(Object, Object) applied to the wrapped references is true and both wrappers use the same equivalence.
    @Nullable T get()
    Returns the (possibly null) reference wrapped by this instance.
    int hashCode()
    Returns the result of Equivalence.hash(Object) applied to the wrapped reference.
    java.lang.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 Details

    • get

      public @Nullable T get()
      Returns the (possibly null) reference wrapped by this instance.
    • equals

      public boolean equals​(@Nullable java.lang.Object obj)
      Returns true if Equivalence.equivalent(Object, Object) applied to the wrapped references is true and both wrappers use the same equivalence.
      Overrides:
      equals in class java.lang.Object
    • hashCode

      public int hashCode()
      Returns the result of Equivalence.hash(Object) applied to the wrapped reference.
      Overrides:
      hashCode in class java.lang.Object
    • toString

      public java.lang.String toString()
      Returns a string representation for this equivalence wrapper. The form of this string representation is not specified.
      Overrides:
      toString in class java.lang.Object