package com.google.common.base; import java.io.Serializable; import javax.annotation.CheckForNull; @ElementTypesAreNonnullByDefault /* loaded from: classes2.dex */ public abstract class Equivalence { protected abstract boolean doEquivalent(T t, T t2); protected abstract int doHash(T t); public final boolean equivalent(@CheckForNull T t, @CheckForNull T t2) { if (t == t2) { return true; } if (t == null || t2 == null) { return false; } return doEquivalent(t, t2); } public final int hash(@CheckForNull T t) { if (t == null) { return 0; } return doHash(t); } public final Equivalence onResultOf(Function function) { return new FunctionalEquivalence(function, this); } public final Wrapper wrap(@ParametricNullness S s) { return new Wrapper<>(s); } /* loaded from: classes2.dex */ public static final class Wrapper implements Serializable { private static final long serialVersionUID = 0; private final Equivalence equivalence; @ParametricNullness private final T reference; @ParametricNullness public T get() { return this.reference; } private Wrapper(Equivalence equivalence, @ParametricNullness T t) { this.equivalence = (Equivalence) Preconditions.checkNotNull(equivalence); this.reference = t; } public boolean equals(@CheckForNull Object obj) { if (obj == this) { return true; } if (!(obj instanceof Wrapper)) { return false; } Wrapper wrapper = (Wrapper) obj; if (this.equivalence.equals(wrapper.equivalence)) { return this.equivalence.equivalent(this.reference, wrapper.reference); } return false; } public int hashCode() { return this.equivalence.hash(this.reference); } public String toString() { String valueOf = String.valueOf(this.equivalence); String valueOf2 = String.valueOf(this.reference); return new StringBuilder(String.valueOf(valueOf).length() + 7 + String.valueOf(valueOf2).length()).append(valueOf).append(".wrap(").append(valueOf2).append(")").toString(); } } public final Equivalence> pairwise() { return new PairwiseEquivalence(this); } public final Predicate equivalentTo(@CheckForNull T t) { return new EquivalentToPredicate(this, t); } /* loaded from: classes2.dex */ private static final class EquivalentToPredicate implements Predicate, Serializable { private static final long serialVersionUID = 0; private final Equivalence equivalence; @CheckForNull private final T target; EquivalentToPredicate(Equivalence equivalence, @CheckForNull T t) { this.equivalence = (Equivalence) Preconditions.checkNotNull(equivalence); this.target = t; } @Override // com.google.common.base.Predicate public boolean apply(@CheckForNull T t) { return this.equivalence.equivalent(t, this.target); } @Override // com.google.common.base.Predicate public boolean equals(@CheckForNull Object obj) { if (this == obj) { return true; } if (!(obj instanceof EquivalentToPredicate)) { return false; } EquivalentToPredicate equivalentToPredicate = (EquivalentToPredicate) obj; return this.equivalence.equals(equivalentToPredicate.equivalence) && Objects.equal(this.target, equivalentToPredicate.target); } public int hashCode() { return Objects.hashCode(this.equivalence, this.target); } public String toString() { String valueOf = String.valueOf(this.equivalence); String valueOf2 = String.valueOf(this.target); return new StringBuilder(String.valueOf(valueOf).length() + 15 + String.valueOf(valueOf2).length()).append(valueOf).append(".equivalentTo(").append(valueOf2).append(")").toString(); } } public static Equivalence equals() { return Equals.INSTANCE; } public static Equivalence identity() { return Identity.INSTANCE; } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public static final class Equals extends Equivalence implements Serializable { static final Equals INSTANCE = new Equals(); private static final long serialVersionUID = 1; private Object readResolve() { return INSTANCE; } Equals() { } @Override // com.google.common.base.Equivalence protected boolean doEquivalent(Object obj, Object obj2) { return obj.equals(obj2); } @Override // com.google.common.base.Equivalence protected int doHash(Object obj) { return obj.hashCode(); } } /* loaded from: classes2.dex */ static final class Identity extends Equivalence implements Serializable { static final Identity INSTANCE = new Identity(); private static final long serialVersionUID = 1; private Object readResolve() { return INSTANCE; } @Override // com.google.common.base.Equivalence protected boolean doEquivalent(Object obj, Object obj2) { return false; } Identity() { } @Override // com.google.common.base.Equivalence protected int doHash(Object obj) { return System.identityHashCode(obj); } } }