mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-15 18:37:17 +01:00
201 lines
6.4 KiB
Java
201 lines
6.4 KiB
Java
package com.google.common.base;
|
|
|
|
import androidx.biometric.ErrorUtils$$ExternalSyntheticOutline0;
|
|
import com.amazon.alexa.ra.core.ui.markdown.parser.formatter.MarkdownConstants;
|
|
import com.google.common.annotations.GwtCompatible;
|
|
import com.google.common.annotations.GwtIncompatible;
|
|
import com.google.common.annotations.J2ktIncompatible;
|
|
import com.google.errorprone.annotations.ForOverride;
|
|
import java.io.Serializable;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@GwtCompatible
|
|
/* loaded from: classes8.dex */
|
|
public abstract class Equivalence<T> {
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static final class Equals extends Equivalence<Object> implements Serializable {
|
|
static final Equals INSTANCE = new Equals();
|
|
|
|
@J2ktIncompatible
|
|
@GwtIncompatible
|
|
private static final long serialVersionUID = 1;
|
|
|
|
private Object readResolve() {
|
|
return INSTANCE;
|
|
}
|
|
|
|
@Override // com.google.common.base.Equivalence
|
|
public boolean doEquivalent(Object obj, Object obj2) {
|
|
return obj.equals(obj2);
|
|
}
|
|
|
|
@Override // com.google.common.base.Equivalence
|
|
public int doHash(Object obj) {
|
|
return obj.hashCode();
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static final class EquivalentToPredicate<T> implements Predicate<T>, Serializable {
|
|
|
|
@J2ktIncompatible
|
|
@GwtIncompatible
|
|
private static final long serialVersionUID = 0;
|
|
private final Equivalence<T> equivalence;
|
|
private final T target;
|
|
|
|
public EquivalentToPredicate(Equivalence<T> equivalence, T t) {
|
|
this.equivalence = (Equivalence) Preconditions.checkNotNull(equivalence);
|
|
this.target = t;
|
|
}
|
|
|
|
@Override // com.google.common.base.Predicate
|
|
public boolean apply(T t) {
|
|
return this.equivalence.equivalent(t, this.target);
|
|
}
|
|
|
|
@Override // com.google.common.base.Predicate
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (obj instanceof EquivalentToPredicate) {
|
|
EquivalentToPredicate equivalentToPredicate = (EquivalentToPredicate) obj;
|
|
if (this.equivalence.equals(equivalentToPredicate.equivalence) && Objects.equal(this.target, equivalentToPredicate.target)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public int hashCode() {
|
|
return Objects.hashCode(this.equivalence, this.target);
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append(this.equivalence);
|
|
sb.append(".equivalentTo(");
|
|
return ErrorUtils$$ExternalSyntheticOutline0.m(sb, MarkdownConstants.RIGHT_PARENTHESIS, this.target);
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static final class Identity extends Equivalence<Object> implements Serializable {
|
|
static final Identity INSTANCE = new Identity();
|
|
|
|
@J2ktIncompatible
|
|
@GwtIncompatible
|
|
private static final long serialVersionUID = 1;
|
|
|
|
private Object readResolve() {
|
|
return INSTANCE;
|
|
}
|
|
|
|
@Override // com.google.common.base.Equivalence
|
|
public boolean doEquivalent(Object obj, Object obj2) {
|
|
return false;
|
|
}
|
|
|
|
@Override // com.google.common.base.Equivalence
|
|
public int doHash(Object obj) {
|
|
return System.identityHashCode(obj);
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static final class Wrapper<T> implements Serializable {
|
|
|
|
@J2ktIncompatible
|
|
@GwtIncompatible
|
|
private static final long serialVersionUID = 0;
|
|
private final Equivalence<? super T> equivalence;
|
|
|
|
@ParametricNullness
|
|
private final T reference;
|
|
|
|
private Wrapper(Equivalence<? super T> equivalence, @ParametricNullness T t) {
|
|
this.equivalence = (Equivalence) Preconditions.checkNotNull(equivalence);
|
|
this.reference = t;
|
|
}
|
|
|
|
public 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;
|
|
}
|
|
|
|
@ParametricNullness
|
|
public T get() {
|
|
return this.reference;
|
|
}
|
|
|
|
public int hashCode() {
|
|
return this.equivalence.hash(this.reference);
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append(this.equivalence);
|
|
sb.append(".wrap(");
|
|
return ErrorUtils$$ExternalSyntheticOutline0.m(sb, MarkdownConstants.RIGHT_PARENTHESIS, this.reference);
|
|
}
|
|
}
|
|
|
|
public static Equivalence<Object> equals() {
|
|
return Equals.INSTANCE;
|
|
}
|
|
|
|
public static Equivalence<Object> identity() {
|
|
return Identity.INSTANCE;
|
|
}
|
|
|
|
@ForOverride
|
|
public abstract boolean doEquivalent(T t, T t2);
|
|
|
|
@ForOverride
|
|
public 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 Predicate<T> equivalentTo(T t) {
|
|
return new EquivalentToPredicate(this, t);
|
|
}
|
|
|
|
public final int hash(T t) {
|
|
if (t == null) {
|
|
return 0;
|
|
}
|
|
return doHash(t);
|
|
}
|
|
|
|
public final <F> Equivalence<F> onResultOf(Function<? super F, ? extends T> function) {
|
|
return new FunctionalEquivalence(function, this);
|
|
}
|
|
|
|
@GwtCompatible(serializable = true)
|
|
public final <S extends T> Equivalence<Iterable<S>> pairwise() {
|
|
return new PairwiseEquivalence(this);
|
|
}
|
|
|
|
public final <S extends T> Wrapper<S> wrap(@ParametricNullness S s) {
|
|
return new Wrapper<>(s);
|
|
}
|
|
}
|