| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class | |
| private static class | |
| pack-priv static class | |
| public static class | Equivalence.Wrapper<T extends @Nullable Object>
Wraps an object so that |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| protected abstract boolean | doEquivalent(T a, T b)
Implemented by the user to determine whether |
| protected abstract int | |
| public static Equivalence | |
| public final boolean | |
| public final Predicate | equivalentTo(T target)
Returns a predicate that evaluates to true if and only if the input is equivalent to |
| public final int | |
| public static Equivalence | identity()
Returns an equivalence that uses |
| public final <F> Equivalence | onResultOf(Function<? super F, ? extends @Nullable T> function)
Returns a new equivalence relation for |
| public final <S extends @Nullable T> Equivalence | |
| public final boolean | test(T
the first input argument t, T the second input argument u)Implements java.
Deprecated
Provided only to satisfy the
Evaluates this predicate on the given arguments.
BiPredicate interface; use equivalent
instead.
|
| public final <S extends @Nullable T> Equivalence. | wrap(S reference)
Returns a wrapper of |
| Equivalence | back to summary |
|---|---|
| protected Equivalence() Constructor for use by subclasses. | |
| doEquivalent | back to summary |
|---|---|
| protected abstract boolean doEquivalent(T a, T b) Implemented by the user to determine whether This method should not be called except by
| |
| doHash | back to summary |
|---|---|
| protected abstract int doHash(T t) Implemented by the user to return a hash code for This method should not be called except by
| |
| equals | back to summary |
|---|---|
| public static Equivalence Returns an equivalence that delegates to
| |
| equivalent | back to summary |
|---|---|
| public final boolean equivalent(T a, T b) Returns This method describes an equivalence relation on object references, meaning that for
all references
Note that all calls to | |
| equivalentTo | back to summary |
|---|---|
| public final Predicate Returns a predicate that evaluates to true if and only if the input is equivalent to
| |
| hash | back to summary |
|---|---|
| public final int hash(T t) Returns a hash code for The
| |
| identity | back to summary |
|---|---|
| public static Equivalence Returns an equivalence that uses
| |
| onResultOf | back to summary |
|---|---|
| public final <F> Equivalence Returns a new equivalence relation for For example:
Note that
| |
| pairwise | back to summary |
|---|---|
| public final <S extends @Nullable T> Equivalence Returns an equivalence over iterables based on the equivalence of their elements. More
specifically, two iterables are considered equivalent if they both contain the same number of
elements, and each pair of corresponding elements is equivalent according to Note that this method performs a similar function for equivalences as The returned object is serializable if this object is serializable.
| |
| test | back to summary |
|---|---|
| public final boolean test(T t, T u) Implements java. Doc from java. Deprecated Provided only to satisfy the Evaluates this predicate on the given arguments.
| |
| wrap | back to summary |
|---|---|
| public final <S extends @Nullable T> Equivalence. Returns a wrapper of The returned object is serializable if both this
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static final Equivalence. | |
| private static final long |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| protected boolean | doEquivalent(Object a, Object b)
Implements abstract com. a and b are considered equivalent,
subject to the requirements specified in equivalent.
|
| protected int | doHash(Object o)
Implements abstract com. t, subject to the requirements
specified in hash.
|
| private Object |
| INSTANCE | back to summary |
|---|---|
| pack-priv static final Equivalence. | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| Equals | back to summary |
|---|---|
| pack-priv Equals() | |
| doEquivalent | back to summary |
|---|---|
| protected boolean doEquivalent(Object a, Object b) Implements abstract com. Doc from com. Implemented by the user to determine whether This method should not be called except by
| |
| doHash | back to summary |
|---|---|
| protected int doHash(Object o) Implements abstract com. Doc from com. Implemented by the user to return a hash code for This method should not be called except by
| |
| readResolve | back to summary |
|---|---|
| private Object readResolve() | |
| Modifier and Type | Field and Description |
|---|---|
| private final Equivalence | |
| private static final long | |
| private final T |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | apply(T input)
Implements com. input (Java 8 users, see notes in the
class documentation above).
|
| public boolean | equals(Object
the reference object with which to compare. obj)Overrides java. Implements com. |
| public int | |
| public String |
| equivalence | back to summary |
|---|---|
| private final Equivalence<T> equivalence | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| target | back to summary |
|---|---|
| private final T target
| |
| EquivalentToPredicate | back to summary |
|---|---|
| pack-priv EquivalentToPredicate(Equivalence<T> equivalence, T target) | |
| apply | back to summary |
|---|---|
| public boolean apply(T input) Implements com. Doc from com. Returns the result of applying this predicate to
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Implements com. Doc from com. Indicates whether another object is equal to this predicate. Most implementations will have no reason to override the behavior of
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static final Equivalence. | |
| private static final long |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| protected boolean | doEquivalent(Object a, Object b)
Implements abstract com. a and b are considered equivalent,
subject to the requirements specified in equivalent.
|
| protected int | doHash(Object o)
Implements abstract com. t, subject to the requirements
specified in hash.
|
| private Object |
| INSTANCE | back to summary |
|---|---|
| pack-priv static final Equivalence. | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| Identity | back to summary |
|---|---|
| pack-priv Identity() | |
| doEquivalent | back to summary |
|---|---|
| protected boolean doEquivalent(Object a, Object b) Implements abstract com. Doc from com. Implemented by the user to determine whether This method should not be called except by
| |
| doHash | back to summary |
|---|---|
| protected int doHash(Object o) Implements abstract com. Doc from com. Implemented by the user to return a hash code for This method should not be called except by
| |
| readResolve | back to summary |
|---|---|
| private Object readResolve() | |
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
| Modifier and Type | Field and Description |
|---|---|
| private final Equivalence | |
| private final T | |
| private static final long |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | equals(Object
the reference object with which to compare. obj)Overrides java. true if Equivalence#equivalent(Object, Object) applied to the wrapped
references is true and both wrappers use the same
equivalence.
|
| public T | |
| public int | hashCode()
Overrides java. Equivalence#hash(Object) applied to the wrapped reference.
|
| public String | toString()
Overrides java. |
| equivalence | back to summary |
|---|---|
| private final Equivalence<? super @NonNull T> equivalence | |
| reference | back to summary |
|---|---|
| private final T reference
| |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| Wrapper | back to summary |
|---|---|
| private Wrapper(Equivalence<? super @NonNull T> equivalence, T reference) | |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Returns
| |
| get | back to summary |
|---|---|
| public T get() Returns the (possibly null) reference wrapped by this instance.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Returns the result of
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns a string representation for this equivalence wrapper. The form of this string representation is not specified.
| |