package com.google.common.collect; import com.google.common.base.Equivalence; import com.google.common.base.Function; import com.google.common.base.Preconditions; import com.google.common.collect.MapMaker; /* loaded from: classes2.dex */ public final class Interners { private Interners() { } /* loaded from: classes2.dex */ public static class InternerBuilder { private final MapMaker mapMaker; private boolean strong; private InternerBuilder() { this.mapMaker = new MapMaker(); this.strong = true; } public InternerBuilder concurrencyLevel(int i) { this.mapMaker.concurrencyLevel(i); return this; } public Interner build() { if (!this.strong) { this.mapMaker.weakKeys(); } return new InternerImpl(this.mapMaker); } public InternerBuilder weak() { this.strong = false; return this; } public InternerBuilder strong() { this.strong = true; return this; } } public static InternerBuilder newBuilder() { return new InternerBuilder(); } public static Interner newStrongInterner() { return newBuilder().strong().build(); } public static Interner newWeakInterner() { return newBuilder().weak().build(); } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public static final class InternerImpl implements Interner { final MapMakerInternalMap map; private InternerImpl(MapMaker mapMaker) { this.map = MapMakerInternalMap.createWithDummyValues(mapMaker.keyEquivalence(Equivalence.equals())); } /* JADX WARN: Type inference failed for: r0v1, types: [com.google.common.collect.MapMakerInternalMap$InternalEntry] */ @Override // com.google.common.collect.Interner public final E intern(E e) { E e2; do { ?? entry = this.map.getEntry(e); if (entry != 0 && (e2 = (E) entry.getKey()) != null) { return e2; } } while (this.map.putIfAbsent(e, MapMaker.Dummy.VALUE) != null); return e; } } public static Function asFunction(Interner interner) { return new InternerFunction((Interner) Preconditions.checkNotNull(interner)); } /* loaded from: classes2.dex */ static class InternerFunction implements Function { private final Interner interner; public InternerFunction(Interner interner) { this.interner = interner; } @Override // com.google.common.base.Function public E apply(E e) { return this.interner.intern(e); } public int hashCode() { return this.interner.hashCode(); } @Override // com.google.common.base.Function public boolean equals(Object obj) { if (obj instanceof InternerFunction) { return this.interner.equals(((InternerFunction) obj).interner); } return false; } } }