com.google.common.base
Class Equivalences

java.lang.Object
  extended by com.google.common.base.Equivalences

@Beta
@GwtCompatible
public final class Equivalences
extends Object

Contains static factory methods for creating Equivalence instances.

All methods return serializable instances.

Since:
4.0
Author:
Bob Lee, Kurt Alfred Kluever, Gregory Kick

Method Summary
static Equivalence<Object> equals()
          Returns an equivalence that delegates to Object.equals(java.lang.Object) and Object.hashCode().
static Equivalence<Object> identity()
          Returns an equivalence that uses == to compare values and System.identityHashCode(Object) to compute the hash code.
static
<T> Equivalence<Iterable<T>>
pairwise(Equivalence<? super T> elementEquivalence)
          Deprecated. use Equivalence.pairwise(), which behaves exactly the same. This method is scheduled for deletion from Guava in Guava release 11.0.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

equals

public static Equivalence<Object> equals()
Returns an equivalence that delegates to Object.equals(java.lang.Object) and Object.hashCode(). Equivalence.equivalent(T, T) returns true if both values are null, or if neither value is null and Object.equals(java.lang.Object) returns true. Equivalence.hash(T) returns 0 if passed a null value.

Since:
8.0 (present null-friendly behavior), 4.0 (otherwise)

identity

public static Equivalence<Object> identity()
Returns an equivalence that uses == to compare values and System.identityHashCode(Object) to compute the hash code. Equivalence.equivalent(T, T) returns true if a == b, including in the case that a and b are both null.


pairwise

@Deprecated
@GwtCompatible(serializable=true)
public static <T> Equivalence<Iterable<T>> pairwise(Equivalence<? super T> elementEquivalence)
Deprecated. use Equivalence.pairwise(), which behaves exactly the same. This method is scheduled for deletion from Guava in Guava release 11.0.

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 elementEquivalence. Null iterables are equivalent to one another.

Since:
9.0


Copyright © 2010-2011. All Rights Reserved.