package com.google.common.base; import java.io.Serializable; /* 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(T t, T t2) { if (t == t2) { return true; } if (t == null || t2 == null) { return false; } return doEquivalent(t, t2); } public final int hash(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(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; private final T reference; private Wrapper(Equivalence equivalence, T t) { this.equivalence = (Equivalence) Preconditions.checkNotNull(equivalence); this.reference = t; } public final boolean equals(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 final int hashCode() { return this.equivalence.hash(this.reference); } public final String toString() { String valueOf = String.valueOf(this.equivalence); String valueOf2 = String.valueOf(this.reference); StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 7 + String.valueOf(valueOf2).length()); sb.append(valueOf); sb.append(".wrap("); sb.append(valueOf2); sb.append(")"); return sb.toString(); } public final T get() { return this.reference; } } public final Equivalence> pairwise() { return new PairwiseEquivalence(this); } public final Predicate equivalentTo(T t) { return new EquivalentToPredicate(this, t); } /* loaded from: classes2.dex */ static final class EquivalentToPredicate implements Predicate, Serializable { private static final long serialVersionUID = 0; private final Equivalence equivalence; private final T target; EquivalentToPredicate(Equivalence equivalence, T t) { this.equivalence = (Equivalence) Preconditions.checkNotNull(equivalence); this.target = t; } @Override // com.google.common.base.Predicate public final boolean apply(T t) { return this.equivalence.equivalent(t, this.target); } @Override // com.google.common.base.Predicate public final boolean equals(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 final int hashCode() { return Objects.hashCode(this.equivalence, this.target); } public final String toString() { String valueOf = String.valueOf(this.equivalence); String valueOf2 = String.valueOf(this.target); StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 15 + String.valueOf(valueOf2).length()); sb.append(valueOf); sb.append(".equivalentTo("); sb.append(valueOf2); sb.append(")"); return sb.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; Equals() { } @Override // com.google.common.base.Equivalence protected final boolean doEquivalent(Object obj, Object obj2) { return obj.equals(obj2); } @Override // com.google.common.base.Equivalence protected final int doHash(Object obj) { return obj.hashCode(); } private Object readResolve() { return INSTANCE; } } /* loaded from: classes2.dex */ static final class Identity extends Equivalence implements Serializable { static final Identity INSTANCE = new Identity(); private static final long serialVersionUID = 1; @Override // com.google.common.base.Equivalence protected final boolean doEquivalent(Object obj, Object obj2) { return false; } Identity() { } @Override // com.google.common.base.Equivalence protected final int doHash(Object obj) { return System.identityHashCode(obj); } private Object readResolve() { return INSTANCE; } } }