001    /*
002     * Copyright (C) 2010 The Guava Authors
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.apache.org/licenses/LICENSE-2.0
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    
017    package com.google.common.base;
018    
019    import com.google.common.annotations.Beta;
020    import com.google.common.annotations.GwtCompatible;
021    
022    /**
023     * Contains static factory methods for creating {@code Equivalence} instances.
024     *
025     * <p>All methods return serializable instances.
026     *
027     * @author Bob Lee
028     * @author Kurt Alfred Kluever
029     * @author Gregory Kick
030     * @since 4.0
031     */
032    @Beta
033    @GwtCompatible
034    public final class Equivalences {
035      private Equivalences() {}
036    
037      /**
038       * Returns an equivalence that delegates to {@link Object#equals} and {@link Object#hashCode}.
039       * {@link Equivalence#equivalent} returns {@code true} if both values are null, or if neither
040       * value is null and {@link Object#equals} returns {@code true}. {@link Equivalence#hash} returns
041       * {@code 0} if passed a null value.
042       *
043       * @since 8.0 (present null-friendly behavior)
044       * @since 4.0 (otherwise)
045       * @deprecated This method has been moved to {@link Equivalence#equals}. This method is scheduled
046       *     to be removed in Guava release 14.0.
047       */
048      @Deprecated
049      public static Equivalence<Object> equals() {
050        return Equivalence.Equals.INSTANCE;
051      }
052    
053      /**
054       * Returns an equivalence that uses {@code ==} to compare values and {@link
055       * System#identityHashCode(Object)} to compute the hash code.  {@link Equivalence#equivalent}
056       * returns {@code true} if {@code a == b}, including in the case that a and b are both null.
057       *
058       * @deprecated This method has been moved to {@link Equivalence#identity}. This method is schedule
059       *     to be removed in Guava release 14.0.
060       */
061      @Deprecated
062      public static Equivalence<Object> identity() {
063        return Equivalence.Identity.INSTANCE;
064      }
065    }