package com.google.common.collect; import com.google.common.base.Converter; import com.google.common.base.Equivalence; import com.google.common.base.Function; import com.google.common.base.Objects; import com.google.common.base.Preconditions; import com.google.common.base.Predicate; import com.google.common.base.Predicates; import com.google.common.collect.ImmutableMap; import com.google.common.collect.MapDifference; import com.google.common.collect.Sets; import defpackage.DeviceControl$Companion$$ExternalSyntheticLambda3; import java.io.Serializable; import java.util.AbstractCollection; import java.util.AbstractMap; import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.EnumMap; import java.util.Enumeration; import java.util.HashMap; import java.util.HashSet; import java.util.IdentityHashMap; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; import java.util.NavigableMap; import java.util.NavigableSet; import java.util.Properties; import java.util.Set; import java.util.SortedMap; import java.util.SortedSet; import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import javax.annotation.CheckForNull; @ElementTypesAreNonnullByDefault /* loaded from: classes3.dex */ public final class Maps { /* JADX INFO: Access modifiers changed from: private */ /* loaded from: classes3.dex */ public enum EntryFunction implements Function, Object> { KEY { // from class: com.google.common.collect.Maps.EntryFunction.1 @Override // com.google.common.base.Function @CheckForNull public Object apply(Map.Entry entry) { return entry.getKey(); } }, VALUE { // from class: com.google.common.collect.Maps.EntryFunction.2 @Override // com.google.common.base.Function @CheckForNull public Object apply(Map.Entry entry) { return entry.getValue(); } } } /* loaded from: classes3.dex */ public interface EntryTransformer { V2 transformEntry(@ParametricNullness K k, @ParametricNullness V1 v1); } private Maps() { } /* JADX INFO: Access modifiers changed from: package-private */ public static Function, K> keyFunction() { return EntryFunction.KEY; } /* JADX INFO: Access modifiers changed from: package-private */ public static Function, V> valueFunction() { return EntryFunction.VALUE; } /* JADX INFO: Access modifiers changed from: package-private */ public static Iterator keyIterator(Iterator> it) { return new TransformedIterator, K>(it) { // from class: com.google.common.collect.Maps.1 /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.TransformedIterator @ParametricNullness public K transform(Map.Entry entry) { return entry.getKey(); } }; } /* JADX INFO: Access modifiers changed from: package-private */ public static Iterator valueIterator(Iterator> it) { return new TransformedIterator, V>(it) { // from class: com.google.common.collect.Maps.2 /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.TransformedIterator @ParametricNullness public V transform(Map.Entry entry) { return entry.getValue(); } }; } public static , V> ImmutableMap immutableEnumMap(Map map) { if (map instanceof ImmutableEnumMap) { return (ImmutableEnumMap) map; } Iterator> it = map.entrySet().iterator(); if (!it.hasNext()) { return ImmutableMap.of(); } Map.Entry next = it.next(); K key = next.getKey(); V value = next.getValue(); CollectPreconditions.checkEntryNotNull(key, value); EnumMap enumMap = new EnumMap(key.getDeclaringClass()); enumMap.put((EnumMap) key, (K) value); while (it.hasNext()) { Map.Entry next2 = it.next(); K key2 = next2.getKey(); V value2 = next2.getValue(); CollectPreconditions.checkEntryNotNull(key2, value2); enumMap.put((EnumMap) key2, (K) value2); } return ImmutableEnumMap.asImmutable(enumMap); } public static HashMap newHashMap() { return new HashMap<>(); } public static HashMap newHashMap(Map map) { return new HashMap<>(map); } public static HashMap newHashMapWithExpectedSize(int i) { return new HashMap<>(capacity(i)); } /* JADX INFO: Access modifiers changed from: package-private */ public static int capacity(int i) { if (i < 3) { CollectPreconditions.checkNonnegative(i, "expectedSize"); return i + 1; } if (i < 1073741824) { return (int) ((i / 0.75f) + 1.0f); } return Integer.MAX_VALUE; } public static LinkedHashMap newLinkedHashMap() { return new LinkedHashMap<>(); } public static LinkedHashMap newLinkedHashMap(Map map) { return new LinkedHashMap<>(map); } public static LinkedHashMap newLinkedHashMapWithExpectedSize(int i) { return new LinkedHashMap<>(capacity(i)); } public static ConcurrentMap newConcurrentMap() { return new ConcurrentHashMap(); } public static TreeMap newTreeMap() { return new TreeMap<>(); } public static TreeMap newTreeMap(SortedMap sortedMap) { return new TreeMap<>((SortedMap) sortedMap); } public static TreeMap newTreeMap(@CheckForNull Comparator comparator) { return new TreeMap<>(comparator); } public static , V> EnumMap newEnumMap(Class cls) { return new EnumMap<>((Class) Preconditions.checkNotNull(cls)); } public static , V> EnumMap newEnumMap(Map map) { return new EnumMap<>(map); } public static IdentityHashMap newIdentityHashMap() { return new IdentityHashMap<>(); } public static MapDifference difference(Map map, Map map2) { if (map instanceof SortedMap) { return difference((SortedMap) map, (Map) map2); } return difference(map, map2, Equivalence.equals()); } public static MapDifference difference(Map map, Map map2, Equivalence equivalence) { Preconditions.checkNotNull(equivalence); LinkedHashMap newLinkedHashMap = newLinkedHashMap(); LinkedHashMap linkedHashMap = new LinkedHashMap(map2); LinkedHashMap newLinkedHashMap2 = newLinkedHashMap(); LinkedHashMap newLinkedHashMap3 = newLinkedHashMap(); doDifference(map, map2, equivalence, newLinkedHashMap, linkedHashMap, newLinkedHashMap2, newLinkedHashMap3); return new MapDifferenceImpl(newLinkedHashMap, linkedHashMap, newLinkedHashMap2, newLinkedHashMap3); } public static SortedMapDifference difference(SortedMap sortedMap, Map map) { Preconditions.checkNotNull(sortedMap); Preconditions.checkNotNull(map); Comparator orNaturalOrder = orNaturalOrder(sortedMap.comparator()); TreeMap newTreeMap = newTreeMap(orNaturalOrder); TreeMap newTreeMap2 = newTreeMap(orNaturalOrder); newTreeMap2.putAll(map); TreeMap newTreeMap3 = newTreeMap(orNaturalOrder); TreeMap newTreeMap4 = newTreeMap(orNaturalOrder); doDifference(sortedMap, map, Equivalence.equals(), newTreeMap, newTreeMap2, newTreeMap3, newTreeMap4); return new SortedMapDifferenceImpl(newTreeMap, newTreeMap2, newTreeMap3, newTreeMap4); } /* JADX WARN: Multi-variable type inference failed */ private static void doDifference(Map map, Map map2, Equivalence equivalence, Map map3, Map map4, Map map5, Map> map6) { for (Map.Entry entry : map.entrySet()) { K key = entry.getKey(); V value = entry.getValue(); if (map2.containsKey(key)) { DeviceControl$Companion$$ExternalSyntheticLambda3 deviceControl$Companion$$ExternalSyntheticLambda3 = (Object) NullnessCasts.uncheckedCastNullableTToT(map4.remove(key)); if (equivalence.equivalent(value, deviceControl$Companion$$ExternalSyntheticLambda3)) { map5.put(key, value); } else { map6.put(key, ValueDifferenceImpl.create(value, deviceControl$Companion$$ExternalSyntheticLambda3)); } } else { map3.put(key, value); } } } /* JADX INFO: Access modifiers changed from: private */ public static Map unmodifiableMap(Map map) { if (map instanceof SortedMap) { return Collections.unmodifiableSortedMap((SortedMap) map); } return Collections.unmodifiableMap(map); } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes3.dex */ public static class MapDifferenceImpl implements MapDifference { final Map> differences; final Map onBoth; final Map onlyOnLeft; final Map onlyOnRight; @Override // com.google.common.collect.MapDifference public Map> entriesDiffering() { return this.differences; } @Override // com.google.common.collect.MapDifference public Map entriesInCommon() { return this.onBoth; } @Override // com.google.common.collect.MapDifference public Map entriesOnlyOnLeft() { return this.onlyOnLeft; } @Override // com.google.common.collect.MapDifference public Map entriesOnlyOnRight() { return this.onlyOnRight; } MapDifferenceImpl(Map map, Map map2, Map map3, Map> map4) { this.onlyOnLeft = Maps.unmodifiableMap(map); this.onlyOnRight = Maps.unmodifiableMap(map2); this.onBoth = Maps.unmodifiableMap(map3); this.differences = Maps.unmodifiableMap(map4); } @Override // com.google.common.collect.MapDifference public boolean areEqual() { return this.onlyOnLeft.isEmpty() && this.onlyOnRight.isEmpty() && this.differences.isEmpty(); } @Override // com.google.common.collect.MapDifference public boolean equals(@CheckForNull Object obj) { if (obj == this) { return true; } if (!(obj instanceof MapDifference)) { return false; } MapDifference mapDifference = (MapDifference) obj; return entriesOnlyOnLeft().equals(mapDifference.entriesOnlyOnLeft()) && entriesOnlyOnRight().equals(mapDifference.entriesOnlyOnRight()) && entriesInCommon().equals(mapDifference.entriesInCommon()) && entriesDiffering().equals(mapDifference.entriesDiffering()); } @Override // com.google.common.collect.MapDifference public int hashCode() { return Objects.hashCode(entriesOnlyOnLeft(), entriesOnlyOnRight(), entriesInCommon(), entriesDiffering()); } public String toString() { if (areEqual()) { return "equal"; } StringBuilder sb = new StringBuilder("not equal"); if (!this.onlyOnLeft.isEmpty()) { sb.append(": only on left=").append(this.onlyOnLeft); } if (!this.onlyOnRight.isEmpty()) { sb.append(": only on right=").append(this.onlyOnRight); } if (!this.differences.isEmpty()) { sb.append(": value differences=").append(this.differences); } return sb.toString(); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes3.dex */ public static class ValueDifferenceImpl implements MapDifference.ValueDifference { @ParametricNullness private final V left; @ParametricNullness private final V right; @Override // com.google.common.collect.MapDifference.ValueDifference @ParametricNullness public V leftValue() { return this.left; } @Override // com.google.common.collect.MapDifference.ValueDifference @ParametricNullness public V rightValue() { return this.right; } static MapDifference.ValueDifference create(@ParametricNullness V v, @ParametricNullness V v2) { return new ValueDifferenceImpl(v, v2); } private ValueDifferenceImpl(@ParametricNullness V v, @ParametricNullness V v2) { this.left = v; this.right = v2; } @Override // com.google.common.collect.MapDifference.ValueDifference public boolean equals(@CheckForNull Object obj) { if (!(obj instanceof MapDifference.ValueDifference)) { return false; } MapDifference.ValueDifference valueDifference = (MapDifference.ValueDifference) obj; return Objects.equal(this.left, valueDifference.leftValue()) && Objects.equal(this.right, valueDifference.rightValue()); } @Override // com.google.common.collect.MapDifference.ValueDifference public int hashCode() { return Objects.hashCode(this.left, this.right); } public String toString() { String valueOf = String.valueOf(this.left); String valueOf2 = String.valueOf(this.right); return new StringBuilder(String.valueOf(valueOf).length() + 4 + String.valueOf(valueOf2).length()).append("(").append(valueOf).append(", ").append(valueOf2).append(")").toString(); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes3.dex */ public static class SortedMapDifferenceImpl extends MapDifferenceImpl implements SortedMapDifference { SortedMapDifferenceImpl(SortedMap sortedMap, SortedMap sortedMap2, SortedMap sortedMap3, SortedMap> sortedMap4) { super(sortedMap, sortedMap2, sortedMap3, sortedMap4); } @Override // com.google.common.collect.Maps.MapDifferenceImpl, com.google.common.collect.MapDifference public SortedMap> entriesDiffering() { return (SortedMap) super.entriesDiffering(); } @Override // com.google.common.collect.Maps.MapDifferenceImpl, com.google.common.collect.MapDifference public SortedMap entriesInCommon() { return (SortedMap) super.entriesInCommon(); } @Override // com.google.common.collect.Maps.MapDifferenceImpl, com.google.common.collect.MapDifference public SortedMap entriesOnlyOnLeft() { return (SortedMap) super.entriesOnlyOnLeft(); } @Override // com.google.common.collect.Maps.MapDifferenceImpl, com.google.common.collect.MapDifference public SortedMap entriesOnlyOnRight() { return (SortedMap) super.entriesOnlyOnRight(); } } static Comparator orNaturalOrder(@CheckForNull Comparator comparator) { return comparator != null ? comparator : Ordering.natural(); } public static Map asMap(Set set, Function function) { return new AsMapView(set, function); } public static SortedMap asMap(SortedSet sortedSet, Function function) { return new SortedAsMapView(sortedSet, function); } public static NavigableMap asMap(NavigableSet navigableSet, Function function) { return new NavigableAsMapView(navigableSet, function); } /* JADX INFO: Access modifiers changed from: private */ /* loaded from: classes3.dex */ public static class AsMapView extends ViewCachingAbstractMap { final Function function; private final Set set; Set backingSet() { return this.set; } AsMapView(Set set, Function function) { this.set = (Set) Preconditions.checkNotNull(set); this.function = (Function) Preconditions.checkNotNull(function); } @Override // com.google.common.collect.Maps.ViewCachingAbstractMap public Set createKeySet() { return Maps.removeOnlySet(backingSet()); } @Override // com.google.common.collect.Maps.ViewCachingAbstractMap Collection createValues() { return Collections2.transform(this.set, this.function); } @Override // java.util.AbstractMap, java.util.Map public int size() { return backingSet().size(); } @Override // java.util.AbstractMap, java.util.Map public boolean containsKey(@CheckForNull Object obj) { return backingSet().contains(obj); } @Override // java.util.AbstractMap, java.util.Map @CheckForNull public V get(@CheckForNull Object obj) { if (Collections2.safeContains(backingSet(), obj)) { return this.function.apply(obj); } return null; } @Override // java.util.AbstractMap, java.util.Map @CheckForNull public V remove(@CheckForNull Object obj) { if (backingSet().remove(obj)) { return this.function.apply(obj); } return null; } @Override // java.util.AbstractMap, java.util.Map public void clear() { backingSet().clear(); } @Override // com.google.common.collect.Maps.ViewCachingAbstractMap protected Set> createEntrySet() { return new EntrySet() { // from class: com.google.common.collect.Maps.AsMapView.1EntrySetImpl @Override // com.google.common.collect.Maps.EntrySet Map map() { return AsMapView.this; } @Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set public Iterator> iterator() { return Maps.asMapEntryIterator(AsMapView.this.backingSet(), AsMapView.this.function); } }; } } /* JADX INFO: Access modifiers changed from: package-private */ public static Iterator> asMapEntryIterator(Set set, final Function function) { return new TransformedIterator>(set.iterator()) { // from class: com.google.common.collect.Maps.3 /* JADX INFO: Access modifiers changed from: package-private */ /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.TransformedIterator public /* bridge */ /* synthetic */ Object transform(@ParametricNullness Object obj) { return transform((AnonymousClass3) obj); } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.TransformedIterator public Map.Entry transform(@ParametricNullness K k) { return Maps.immutableEntry(k, function.apply(k)); } }; } /* JADX INFO: Access modifiers changed from: private */ /* loaded from: classes3.dex */ public static class SortedAsMapView extends AsMapView implements SortedMap { SortedAsMapView(SortedSet sortedSet, Function function) { super(sortedSet, function); } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.Maps.AsMapView public SortedSet backingSet() { return (SortedSet) super.backingSet(); } @Override // java.util.SortedMap @CheckForNull public Comparator comparator() { return backingSet().comparator(); } @Override // com.google.common.collect.Maps.ViewCachingAbstractMap, java.util.AbstractMap, java.util.Map public Set keySet() { return Maps.removeOnlySortedSet(backingSet()); } @Override // java.util.SortedMap public SortedMap subMap(@ParametricNullness K k, @ParametricNullness K k2) { return Maps.asMap((SortedSet) backingSet().subSet(k, k2), (Function) this.function); } @Override // java.util.SortedMap public SortedMap headMap(@ParametricNullness K k) { return Maps.asMap((SortedSet) backingSet().headSet(k), (Function) this.function); } @Override // java.util.SortedMap public SortedMap tailMap(@ParametricNullness K k) { return Maps.asMap((SortedSet) backingSet().tailSet(k), (Function) this.function); } @Override // java.util.SortedMap @ParametricNullness public K firstKey() { return backingSet().first(); } @Override // java.util.SortedMap @ParametricNullness public K lastKey() { return backingSet().last(); } } /* JADX INFO: Access modifiers changed from: private */ /* loaded from: classes3.dex */ public static final class NavigableAsMapView extends AbstractNavigableMap { private final Function function; private final NavigableSet set; NavigableAsMapView(NavigableSet navigableSet, Function function) { this.set = (NavigableSet) Preconditions.checkNotNull(navigableSet); this.function = (Function) Preconditions.checkNotNull(function); } @Override // java.util.NavigableMap public NavigableMap subMap(@ParametricNullness K k, boolean z, @ParametricNullness K k2, boolean z2) { return Maps.asMap((NavigableSet) this.set.subSet(k, z, k2, z2), (Function) this.function); } @Override // java.util.NavigableMap public NavigableMap headMap(@ParametricNullness K k, boolean z) { return Maps.asMap((NavigableSet) this.set.headSet(k, z), (Function) this.function); } @Override // java.util.NavigableMap public NavigableMap tailMap(@ParametricNullness K k, boolean z) { return Maps.asMap((NavigableSet) this.set.tailSet(k, z), (Function) this.function); } @Override // java.util.SortedMap @CheckForNull public Comparator comparator() { return this.set.comparator(); } @Override // com.google.common.collect.AbstractNavigableMap, java.util.AbstractMap, java.util.Map @CheckForNull public V get(@CheckForNull Object obj) { if (Collections2.safeContains(this.set, obj)) { return this.function.apply(obj); } return null; } @Override // com.google.common.collect.Maps.IteratorBasedAbstractMap, java.util.AbstractMap, java.util.Map public void clear() { this.set.clear(); } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.Maps.IteratorBasedAbstractMap public Iterator> entryIterator() { return Maps.asMapEntryIterator(this.set, this.function); } @Override // com.google.common.collect.AbstractNavigableMap Iterator> descendingEntryIterator() { return descendingMap().entrySet().iterator(); } @Override // com.google.common.collect.AbstractNavigableMap, java.util.NavigableMap public NavigableSet navigableKeySet() { return Maps.removeOnlyNavigableSet(this.set); } @Override // com.google.common.collect.Maps.IteratorBasedAbstractMap, java.util.AbstractMap, java.util.Map public int size() { return this.set.size(); } @Override // com.google.common.collect.AbstractNavigableMap, java.util.NavigableMap public NavigableMap descendingMap() { return Maps.asMap((NavigableSet) this.set.descendingSet(), (Function) this.function); } } /* JADX INFO: Access modifiers changed from: private */ public static Set removeOnlySet(final Set set) { return new ForwardingSet() { // from class: com.google.common.collect.Maps.4 /* JADX INFO: Access modifiers changed from: protected */ @Override // com.google.common.collect.ForwardingSet, com.google.common.collect.ForwardingCollection, com.google.common.collect.ForwardingObject public Set delegate() { return set; } @Override // com.google.common.collect.ForwardingCollection, java.util.Collection, java.util.Queue public boolean add(@ParametricNullness E e) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.ForwardingCollection, java.util.Collection public boolean addAll(Collection collection) { throw new UnsupportedOperationException(); } }; } /* JADX INFO: Access modifiers changed from: private */ public static SortedSet removeOnlySortedSet(final SortedSet sortedSet) { return new ForwardingSortedSet() { // from class: com.google.common.collect.Maps.5 /* JADX INFO: Access modifiers changed from: protected */ @Override // com.google.common.collect.ForwardingSortedSet, com.google.common.collect.ForwardingSet, com.google.common.collect.ForwardingCollection, com.google.common.collect.ForwardingObject public SortedSet delegate() { return sortedSet; } @Override // com.google.common.collect.ForwardingCollection, java.util.Collection, java.util.Queue public boolean add(@ParametricNullness E e) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.ForwardingCollection, java.util.Collection public boolean addAll(Collection collection) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.ForwardingSortedSet, java.util.SortedSet public SortedSet headSet(@ParametricNullness E e) { return Maps.removeOnlySortedSet(super.headSet(e)); } @Override // com.google.common.collect.ForwardingSortedSet, java.util.SortedSet public SortedSet subSet(@ParametricNullness E e, @ParametricNullness E e2) { return Maps.removeOnlySortedSet(super.subSet(e, e2)); } @Override // com.google.common.collect.ForwardingSortedSet, java.util.SortedSet public SortedSet tailSet(@ParametricNullness E e) { return Maps.removeOnlySortedSet(super.tailSet(e)); } }; } /* JADX INFO: Access modifiers changed from: private */ public static NavigableSet removeOnlyNavigableSet(final NavigableSet navigableSet) { return new ForwardingNavigableSet() { // from class: com.google.common.collect.Maps.6 /* JADX INFO: Access modifiers changed from: protected */ @Override // com.google.common.collect.ForwardingNavigableSet, com.google.common.collect.ForwardingSortedSet, com.google.common.collect.ForwardingSet, com.google.common.collect.ForwardingCollection, com.google.common.collect.ForwardingObject public NavigableSet delegate() { return navigableSet; } @Override // com.google.common.collect.ForwardingCollection, java.util.Collection, java.util.Queue public boolean add(@ParametricNullness E e) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.ForwardingCollection, java.util.Collection public boolean addAll(Collection collection) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.ForwardingSortedSet, java.util.SortedSet public SortedSet headSet(@ParametricNullness E e) { return Maps.removeOnlySortedSet(super.headSet(e)); } @Override // com.google.common.collect.ForwardingNavigableSet, java.util.NavigableSet public NavigableSet headSet(@ParametricNullness E e, boolean z) { return Maps.removeOnlyNavigableSet(super.headSet(e, z)); } @Override // com.google.common.collect.ForwardingSortedSet, java.util.SortedSet public SortedSet subSet(@ParametricNullness E e, @ParametricNullness E e2) { return Maps.removeOnlySortedSet(super.subSet(e, e2)); } @Override // com.google.common.collect.ForwardingNavigableSet, java.util.NavigableSet public NavigableSet subSet(@ParametricNullness E e, boolean z, @ParametricNullness E e2, boolean z2) { return Maps.removeOnlyNavigableSet(super.subSet(e, z, e2, z2)); } @Override // com.google.common.collect.ForwardingSortedSet, java.util.SortedSet public SortedSet tailSet(@ParametricNullness E e) { return Maps.removeOnlySortedSet(super.tailSet(e)); } @Override // com.google.common.collect.ForwardingNavigableSet, java.util.NavigableSet public NavigableSet tailSet(@ParametricNullness E e, boolean z) { return Maps.removeOnlyNavigableSet(super.tailSet(e, z)); } @Override // com.google.common.collect.ForwardingNavigableSet, java.util.NavigableSet public NavigableSet descendingSet() { return Maps.removeOnlyNavigableSet(super.descendingSet()); } }; } public static ImmutableMap toMap(Iterable iterable, Function function) { return toMap(iterable.iterator(), function); } public static ImmutableMap toMap(Iterator it, Function function) { Preconditions.checkNotNull(function); ImmutableMap.Builder builder = ImmutableMap.builder(); while (it.hasNext()) { K next = it.next(); builder.put(next, function.apply(next)); } return builder.buildKeepingLast(); } public static ImmutableMap uniqueIndex(Iterable iterable, Function function) { return uniqueIndex(iterable.iterator(), function); } public static ImmutableMap uniqueIndex(Iterator it, Function function) { Preconditions.checkNotNull(function); ImmutableMap.Builder builder = ImmutableMap.builder(); while (it.hasNext()) { V next = it.next(); builder.put(function.apply(next), next); } try { return builder.buildOrThrow(); } catch (IllegalArgumentException e) { throw new IllegalArgumentException(String.valueOf(e.getMessage()).concat(". To index multiple values under a key, use Multimaps.index.")); } } public static ImmutableMap fromProperties(Properties properties) { ImmutableMap.Builder builder = ImmutableMap.builder(); Enumeration propertyNames = properties.propertyNames(); while (propertyNames.hasMoreElements()) { String str = (String) java.util.Objects.requireNonNull(propertyNames.nextElement()); builder.put(str, (String) java.util.Objects.requireNonNull(properties.getProperty(str))); } return builder.buildOrThrow(); } public static Map.Entry immutableEntry(@ParametricNullness K k, @ParametricNullness V v) { return new ImmutableEntry(k, v); } /* JADX INFO: Access modifiers changed from: package-private */ public static Set> unmodifiableEntrySet(Set> set) { return new UnmodifiableEntrySet(Collections.unmodifiableSet(set)); } static Map.Entry unmodifiableEntry(final Map.Entry entry) { Preconditions.checkNotNull(entry); return new AbstractMapEntry() { // from class: com.google.common.collect.Maps.7 @Override // com.google.common.collect.AbstractMapEntry, java.util.Map.Entry @ParametricNullness public K getKey() { return (K) entry.getKey(); } @Override // com.google.common.collect.AbstractMapEntry, java.util.Map.Entry @ParametricNullness public V getValue() { return (V) entry.getValue(); } }; } /* JADX INFO: Access modifiers changed from: package-private */ public static UnmodifiableIterator> unmodifiableEntryIterator(final Iterator> it) { return new UnmodifiableIterator>() { // from class: com.google.common.collect.Maps.8 @Override // java.util.Iterator public boolean hasNext() { return it.hasNext(); } @Override // java.util.Iterator public Map.Entry next() { return Maps.unmodifiableEntry((Map.Entry) it.next()); } }; } /* loaded from: classes3.dex */ static class UnmodifiableEntries extends ForwardingCollection> { private final Collection> entries; /* JADX INFO: Access modifiers changed from: protected */ @Override // com.google.common.collect.ForwardingCollection, com.google.common.collect.ForwardingObject public Collection> delegate() { return this.entries; } /* JADX INFO: Access modifiers changed from: package-private */ public UnmodifiableEntries(Collection> collection) { this.entries = collection; } @Override // com.google.common.collect.ForwardingCollection, java.util.Collection, java.lang.Iterable, java.util.Set public Iterator> iterator() { return Maps.unmodifiableEntryIterator(this.entries.iterator()); } @Override // com.google.common.collect.ForwardingCollection, java.util.Collection, java.util.Set public Object[] toArray() { return standardToArray(); } @Override // com.google.common.collect.ForwardingCollection, java.util.Collection, java.util.Set public T[] toArray(T[] tArr) { return (T[]) standardToArray(tArr); } } /* loaded from: classes3.dex */ static class UnmodifiableEntrySet extends UnmodifiableEntries implements Set> { UnmodifiableEntrySet(Set> set) { super(set); } @Override // java.util.Collection, java.util.Set public boolean equals(@CheckForNull Object obj) { return Sets.equalsImpl(this, obj); } @Override // java.util.Collection, java.util.Set public int hashCode() { return Sets.hashCodeImpl(this); } } public static Converter asConverter(BiMap biMap) { return new BiMapConverter(biMap); } /* loaded from: classes3.dex */ private static final class BiMapConverter extends Converter implements Serializable { private static final long serialVersionUID = 0; private final BiMap bimap; BiMapConverter(BiMap biMap) { this.bimap = (BiMap) Preconditions.checkNotNull(biMap); } @Override // com.google.common.base.Converter protected B doForward(A a) { return (B) convert(this.bimap, a); } @Override // com.google.common.base.Converter protected A doBackward(B b) { return (A) convert(this.bimap.inverse(), b); } private static Y convert(BiMap biMap, X x) { Y y = biMap.get(x); Preconditions.checkArgument(y != null, "No non-null mapping present for input: %s", x); return y; } @Override // com.google.common.base.Converter, com.google.common.base.Function public boolean equals(@CheckForNull Object obj) { if (obj instanceof BiMapConverter) { return this.bimap.equals(((BiMapConverter) obj).bimap); } return false; } public int hashCode() { return this.bimap.hashCode(); } public String toString() { String valueOf = String.valueOf(this.bimap); return new StringBuilder(String.valueOf(valueOf).length() + 18).append("Maps.asConverter(").append(valueOf).append(")").toString(); } } public static BiMap synchronizedBiMap(BiMap biMap) { return Synchronized.biMap(biMap, null); } public static BiMap unmodifiableBiMap(BiMap biMap) { return new UnmodifiableBiMap(biMap, null); } /* loaded from: classes3.dex */ private static class UnmodifiableBiMap extends ForwardingMap implements BiMap, Serializable { private static final long serialVersionUID = 0; final BiMap delegate; @CheckForNull BiMap inverse; final Map unmodifiableMap; @CheckForNull transient Set values; /* JADX INFO: Access modifiers changed from: protected */ @Override // com.google.common.collect.ForwardingMap, com.google.common.collect.ForwardingObject public Map delegate() { return this.unmodifiableMap; } UnmodifiableBiMap(BiMap biMap, @CheckForNull BiMap biMap2) { this.unmodifiableMap = Collections.unmodifiableMap(biMap); this.delegate = biMap; this.inverse = biMap2; } @Override // com.google.common.collect.BiMap @CheckForNull public V forcePut(@ParametricNullness K k, @ParametricNullness V v) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.BiMap public BiMap inverse() { BiMap biMap = this.inverse; if (biMap != null) { return biMap; } UnmodifiableBiMap unmodifiableBiMap = new UnmodifiableBiMap(this.delegate.inverse(), this); this.inverse = unmodifiableBiMap; return unmodifiableBiMap; } @Override // com.google.common.collect.ForwardingMap, java.util.Map, com.google.common.collect.BiMap public Set values() { Set set = this.values; if (set != null) { return set; } Set unmodifiableSet = Collections.unmodifiableSet(this.delegate.values()); this.values = unmodifiableSet; return unmodifiableSet; } } public static Map transformValues(Map map, Function function) { return transformEntries(map, asEntryTransformer(function)); } public static SortedMap transformValues(SortedMap sortedMap, Function function) { return transformEntries((SortedMap) sortedMap, asEntryTransformer(function)); } public static NavigableMap transformValues(NavigableMap navigableMap, Function function) { return transformEntries((NavigableMap) navigableMap, asEntryTransformer(function)); } public static Map transformEntries(Map map, EntryTransformer entryTransformer) { return new TransformedEntriesMap(map, entryTransformer); } public static SortedMap transformEntries(SortedMap sortedMap, EntryTransformer entryTransformer) { return new TransformedEntriesSortedMap(sortedMap, entryTransformer); } public static NavigableMap transformEntries(NavigableMap navigableMap, EntryTransformer entryTransformer) { return new TransformedEntriesNavigableMap(navigableMap, entryTransformer); } /* JADX INFO: Access modifiers changed from: package-private */ public static EntryTransformer asEntryTransformer(final Function function) { Preconditions.checkNotNull(function); return new EntryTransformer() { // from class: com.google.common.collect.Maps.9 @Override // com.google.common.collect.Maps.EntryTransformer @ParametricNullness public V2 transformEntry(@ParametricNullness K k, @ParametricNullness V1 v1) { return (V2) Function.this.apply(v1); } }; } /* JADX INFO: Access modifiers changed from: package-private */ public static Function asValueToValueFunction(final EntryTransformer entryTransformer, @ParametricNullness final K k) { Preconditions.checkNotNull(entryTransformer); return new Function() { // from class: com.google.common.collect.Maps.10 @Override // com.google.common.base.Function @ParametricNullness public V2 apply(@ParametricNullness V1 v1) { return (V2) EntryTransformer.this.transformEntry(k, v1); } }; } /* JADX INFO: Access modifiers changed from: package-private */ public static Function, V2> asEntryToValueFunction(final EntryTransformer entryTransformer) { Preconditions.checkNotNull(entryTransformer); return new Function, V2>() { // from class: com.google.common.collect.Maps.11 @Override // com.google.common.base.Function @ParametricNullness public V2 apply(Map.Entry entry) { return (V2) EntryTransformer.this.transformEntry(entry.getKey(), entry.getValue()); } }; } static Map.Entry transformEntry(final EntryTransformer entryTransformer, final Map.Entry entry) { Preconditions.checkNotNull(entryTransformer); Preconditions.checkNotNull(entry); return new AbstractMapEntry() { // from class: com.google.common.collect.Maps.12 @Override // com.google.common.collect.AbstractMapEntry, java.util.Map.Entry @ParametricNullness public K getKey() { return (K) entry.getKey(); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.AbstractMapEntry, java.util.Map.Entry @ParametricNullness public V2 getValue() { return (V2) entryTransformer.transformEntry(entry.getKey(), entry.getValue()); } }; } /* JADX INFO: Access modifiers changed from: package-private */ public static Function, Map.Entry> asEntryToEntryFunction(final EntryTransformer entryTransformer) { Preconditions.checkNotNull(entryTransformer); return new Function, Map.Entry>() { // from class: com.google.common.collect.Maps.13 @Override // com.google.common.base.Function public Map.Entry apply(Map.Entry entry) { return Maps.transformEntry(EntryTransformer.this, entry); } }; } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes3.dex */ public static class TransformedEntriesMap extends IteratorBasedAbstractMap { final Map fromMap; final EntryTransformer transformer; TransformedEntriesMap(Map map, EntryTransformer entryTransformer) { this.fromMap = (Map) Preconditions.checkNotNull(map); this.transformer = (EntryTransformer) Preconditions.checkNotNull(entryTransformer); } @Override // com.google.common.collect.Maps.IteratorBasedAbstractMap, java.util.AbstractMap, java.util.Map public int size() { return this.fromMap.size(); } @Override // java.util.AbstractMap, java.util.Map public boolean containsKey(@CheckForNull Object obj) { return this.fromMap.containsKey(obj); } @Override // java.util.AbstractMap, java.util.Map @CheckForNull public V2 get(@CheckForNull Object obj) { V1 v1 = this.fromMap.get(obj); if (v1 != null || this.fromMap.containsKey(obj)) { return this.transformer.transformEntry(obj, (Object) NullnessCasts.uncheckedCastNullableTToT(v1)); } return null; } @Override // java.util.AbstractMap, java.util.Map @CheckForNull public V2 remove(@CheckForNull Object obj) { if (this.fromMap.containsKey(obj)) { return this.transformer.transformEntry(obj, (Object) NullnessCasts.uncheckedCastNullableTToT(this.fromMap.remove(obj))); } return null; } @Override // com.google.common.collect.Maps.IteratorBasedAbstractMap, java.util.AbstractMap, java.util.Map public void clear() { this.fromMap.clear(); } @Override // java.util.AbstractMap, java.util.Map public Set keySet() { return this.fromMap.keySet(); } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.Maps.IteratorBasedAbstractMap public Iterator> entryIterator() { return Iterators.transform(this.fromMap.entrySet().iterator(), Maps.asEntryToEntryFunction(this.transformer)); } @Override // java.util.AbstractMap, java.util.Map public Collection values() { return new Values(this); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes3.dex */ public static class TransformedEntriesSortedMap extends TransformedEntriesMap implements SortedMap { protected SortedMap fromMap() { return (SortedMap) this.fromMap; } TransformedEntriesSortedMap(SortedMap sortedMap, EntryTransformer entryTransformer) { super(sortedMap, entryTransformer); } @Override // java.util.SortedMap @CheckForNull public Comparator comparator() { return fromMap().comparator(); } @Override // java.util.SortedMap @ParametricNullness public K firstKey() { return fromMap().firstKey(); } public SortedMap headMap(@ParametricNullness K k) { return Maps.transformEntries((SortedMap) fromMap().headMap(k), (EntryTransformer) this.transformer); } @Override // java.util.SortedMap @ParametricNullness public K lastKey() { return fromMap().lastKey(); } public SortedMap subMap(@ParametricNullness K k, @ParametricNullness K k2) { return Maps.transformEntries((SortedMap) fromMap().subMap(k, k2), (EntryTransformer) this.transformer); } public SortedMap tailMap(@ParametricNullness K k) { return Maps.transformEntries((SortedMap) fromMap().tailMap(k), (EntryTransformer) this.transformer); } } /* JADX INFO: Access modifiers changed from: private */ /* loaded from: classes3.dex */ public static class TransformedEntriesNavigableMap extends TransformedEntriesSortedMap implements NavigableMap { /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.Maps.TransformedEntriesSortedMap, java.util.SortedMap, java.util.NavigableMap public /* bridge */ /* synthetic */ SortedMap headMap(@ParametricNullness Object obj) { return headMap((TransformedEntriesNavigableMap) obj); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.Maps.TransformedEntriesSortedMap, java.util.SortedMap, java.util.NavigableMap public /* bridge */ /* synthetic */ SortedMap tailMap(@ParametricNullness Object obj) { return tailMap((TransformedEntriesNavigableMap) obj); } TransformedEntriesNavigableMap(NavigableMap navigableMap, EntryTransformer entryTransformer) { super(navigableMap, entryTransformer); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry ceilingEntry(@ParametricNullness K k) { return transformEntry(fromMap().ceilingEntry(k)); } @Override // java.util.NavigableMap @CheckForNull public K ceilingKey(@ParametricNullness K k) { return fromMap().ceilingKey(k); } @Override // java.util.NavigableMap public NavigableSet descendingKeySet() { return fromMap().descendingKeySet(); } @Override // java.util.NavigableMap public NavigableMap descendingMap() { return Maps.transformEntries((NavigableMap) fromMap().descendingMap(), (EntryTransformer) this.transformer); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry firstEntry() { return transformEntry(fromMap().firstEntry()); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry floorEntry(@ParametricNullness K k) { return transformEntry(fromMap().floorEntry(k)); } @Override // java.util.NavigableMap @CheckForNull public K floorKey(@ParametricNullness K k) { return fromMap().floorKey(k); } @Override // com.google.common.collect.Maps.TransformedEntriesSortedMap, java.util.SortedMap, java.util.NavigableMap public NavigableMap headMap(@ParametricNullness K k) { return headMap(k, false); } @Override // java.util.NavigableMap public NavigableMap headMap(@ParametricNullness K k, boolean z) { return Maps.transformEntries((NavigableMap) fromMap().headMap(k, z), (EntryTransformer) this.transformer); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry higherEntry(@ParametricNullness K k) { return transformEntry(fromMap().higherEntry(k)); } @Override // java.util.NavigableMap @CheckForNull public K higherKey(@ParametricNullness K k) { return fromMap().higherKey(k); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry lastEntry() { return transformEntry(fromMap().lastEntry()); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry lowerEntry(@ParametricNullness K k) { return transformEntry(fromMap().lowerEntry(k)); } @Override // java.util.NavigableMap @CheckForNull public K lowerKey(@ParametricNullness K k) { return fromMap().lowerKey(k); } @Override // java.util.NavigableMap public NavigableSet navigableKeySet() { return fromMap().navigableKeySet(); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry pollFirstEntry() { return transformEntry(fromMap().pollFirstEntry()); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry pollLastEntry() { return transformEntry(fromMap().pollLastEntry()); } @Override // java.util.NavigableMap public NavigableMap subMap(@ParametricNullness K k, boolean z, @ParametricNullness K k2, boolean z2) { return Maps.transformEntries((NavigableMap) fromMap().subMap(k, z, k2, z2), (EntryTransformer) this.transformer); } @Override // com.google.common.collect.Maps.TransformedEntriesSortedMap, java.util.SortedMap, java.util.NavigableMap public NavigableMap subMap(@ParametricNullness K k, @ParametricNullness K k2) { return subMap(k, true, k2, false); } @Override // com.google.common.collect.Maps.TransformedEntriesSortedMap, java.util.SortedMap, java.util.NavigableMap public NavigableMap tailMap(@ParametricNullness K k) { return tailMap(k, true); } @Override // java.util.NavigableMap public NavigableMap tailMap(@ParametricNullness K k, boolean z) { return Maps.transformEntries((NavigableMap) fromMap().tailMap(k, z), (EntryTransformer) this.transformer); } @CheckForNull private Map.Entry transformEntry(@CheckForNull Map.Entry entry) { if (entry == null) { return null; } return Maps.transformEntry(this.transformer, entry); } /* JADX INFO: Access modifiers changed from: protected */ @Override // com.google.common.collect.Maps.TransformedEntriesSortedMap public NavigableMap fromMap() { return (NavigableMap) super.fromMap(); } } /* JADX INFO: Access modifiers changed from: package-private */ public static Predicate> keyPredicateOnEntries(Predicate predicate) { return Predicates.compose(predicate, keyFunction()); } /* JADX INFO: Access modifiers changed from: package-private */ public static Predicate> valuePredicateOnEntries(Predicate predicate) { return Predicates.compose(predicate, valueFunction()); } public static Map filterKeys(Map map, Predicate predicate) { Preconditions.checkNotNull(predicate); Predicate keyPredicateOnEntries = keyPredicateOnEntries(predicate); if (map instanceof AbstractFilteredMap) { return filterFiltered((AbstractFilteredMap) map, keyPredicateOnEntries); } return new FilteredKeyMap((Map) Preconditions.checkNotNull(map), predicate, keyPredicateOnEntries); } public static SortedMap filterKeys(SortedMap sortedMap, Predicate predicate) { return filterEntries((SortedMap) sortedMap, keyPredicateOnEntries(predicate)); } public static NavigableMap filterKeys(NavigableMap navigableMap, Predicate predicate) { return filterEntries((NavigableMap) navigableMap, keyPredicateOnEntries(predicate)); } public static BiMap filterKeys(BiMap biMap, Predicate predicate) { Preconditions.checkNotNull(predicate); return filterEntries((BiMap) biMap, keyPredicateOnEntries(predicate)); } public static Map filterValues(Map map, Predicate predicate) { return filterEntries(map, valuePredicateOnEntries(predicate)); } public static SortedMap filterValues(SortedMap sortedMap, Predicate predicate) { return filterEntries((SortedMap) sortedMap, valuePredicateOnEntries(predicate)); } public static NavigableMap filterValues(NavigableMap navigableMap, Predicate predicate) { return filterEntries((NavigableMap) navigableMap, valuePredicateOnEntries(predicate)); } public static BiMap filterValues(BiMap biMap, Predicate predicate) { return filterEntries((BiMap) biMap, valuePredicateOnEntries(predicate)); } public static Map filterEntries(Map map, Predicate> predicate) { Preconditions.checkNotNull(predicate); if (map instanceof AbstractFilteredMap) { return filterFiltered((AbstractFilteredMap) map, predicate); } return new FilteredEntryMap((Map) Preconditions.checkNotNull(map), predicate); } public static SortedMap filterEntries(SortedMap sortedMap, Predicate> predicate) { Preconditions.checkNotNull(predicate); if (sortedMap instanceof FilteredEntrySortedMap) { return filterFiltered((FilteredEntrySortedMap) sortedMap, (Predicate) predicate); } return new FilteredEntrySortedMap((SortedMap) Preconditions.checkNotNull(sortedMap), predicate); } public static NavigableMap filterEntries(NavigableMap navigableMap, Predicate> predicate) { Preconditions.checkNotNull(predicate); if (navigableMap instanceof FilteredEntryNavigableMap) { return filterFiltered((FilteredEntryNavigableMap) navigableMap, predicate); } return new FilteredEntryNavigableMap((NavigableMap) Preconditions.checkNotNull(navigableMap), predicate); } public static BiMap filterEntries(BiMap biMap, Predicate> predicate) { Preconditions.checkNotNull(biMap); Preconditions.checkNotNull(predicate); if (biMap instanceof FilteredEntryBiMap) { return filterFiltered((FilteredEntryBiMap) biMap, (Predicate) predicate); } return new FilteredEntryBiMap(biMap, predicate); } private static Map filterFiltered(AbstractFilteredMap abstractFilteredMap, Predicate> predicate) { return new FilteredEntryMap(abstractFilteredMap.unfiltered, Predicates.and(abstractFilteredMap.predicate, predicate)); } private static SortedMap filterFiltered(FilteredEntrySortedMap filteredEntrySortedMap, Predicate> predicate) { return new FilteredEntrySortedMap(filteredEntrySortedMap.sortedMap(), Predicates.and(filteredEntrySortedMap.predicate, predicate)); } private static NavigableMap filterFiltered(FilteredEntryNavigableMap filteredEntryNavigableMap, Predicate> predicate) { return new FilteredEntryNavigableMap(((FilteredEntryNavigableMap) filteredEntryNavigableMap).unfiltered, Predicates.and(((FilteredEntryNavigableMap) filteredEntryNavigableMap).entryPredicate, predicate)); } private static BiMap filterFiltered(FilteredEntryBiMap filteredEntryBiMap, Predicate> predicate) { return new FilteredEntryBiMap(filteredEntryBiMap.unfiltered(), Predicates.and(filteredEntryBiMap.predicate, predicate)); } /* JADX INFO: Access modifiers changed from: private */ /* loaded from: classes3.dex */ public static abstract class AbstractFilteredMap extends ViewCachingAbstractMap { final Predicate> predicate; final Map unfiltered; AbstractFilteredMap(Map map, Predicate> predicate) { this.unfiltered = map; this.predicate = predicate; } boolean apply(@CheckForNull Object obj, @ParametricNullness V v) { return this.predicate.apply(Maps.immutableEntry(obj, v)); } @Override // java.util.AbstractMap, java.util.Map @CheckForNull public V put(@ParametricNullness K k, @ParametricNullness V v) { Preconditions.checkArgument(apply(k, v)); return this.unfiltered.put(k, v); } @Override // java.util.AbstractMap, java.util.Map public void putAll(Map map) { for (Map.Entry entry : map.entrySet()) { Preconditions.checkArgument(apply(entry.getKey(), entry.getValue())); } this.unfiltered.putAll(map); } @Override // java.util.AbstractMap, java.util.Map public boolean containsKey(@CheckForNull Object obj) { return this.unfiltered.containsKey(obj) && apply(obj, this.unfiltered.get(obj)); } @Override // java.util.AbstractMap, java.util.Map @CheckForNull public V get(@CheckForNull Object obj) { V v = this.unfiltered.get(obj); if (v == null || !apply(obj, v)) { return null; } return v; } @Override // java.util.AbstractMap, java.util.Map public boolean isEmpty() { return entrySet().isEmpty(); } @Override // java.util.AbstractMap, java.util.Map @CheckForNull public V remove(@CheckForNull Object obj) { if (containsKey(obj)) { return this.unfiltered.remove(obj); } return null; } @Override // com.google.common.collect.Maps.ViewCachingAbstractMap Collection createValues() { return new FilteredMapValues(this, this.unfiltered, this.predicate); } } /* loaded from: classes3.dex */ private static final class FilteredMapValues extends Values { final Predicate> predicate; final Map unfiltered; FilteredMapValues(Map map, Map map2, Predicate> predicate) { super(map); this.unfiltered = map2; this.predicate = predicate; } @Override // com.google.common.collect.Maps.Values, java.util.AbstractCollection, java.util.Collection public boolean remove(@CheckForNull Object obj) { Iterator> it = this.unfiltered.entrySet().iterator(); while (it.hasNext()) { Map.Entry next = it.next(); if (this.predicate.apply(next) && Objects.equal(next.getValue(), obj)) { it.remove(); return true; } } return false; } @Override // com.google.common.collect.Maps.Values, java.util.AbstractCollection, java.util.Collection public boolean removeAll(Collection collection) { Iterator> it = this.unfiltered.entrySet().iterator(); boolean z = false; while (it.hasNext()) { Map.Entry next = it.next(); if (this.predicate.apply(next) && collection.contains(next.getValue())) { it.remove(); z = true; } } return z; } @Override // com.google.common.collect.Maps.Values, java.util.AbstractCollection, java.util.Collection public boolean retainAll(Collection collection) { Iterator> it = this.unfiltered.entrySet().iterator(); boolean z = false; while (it.hasNext()) { Map.Entry next = it.next(); if (this.predicate.apply(next) && !collection.contains(next.getValue())) { it.remove(); z = true; } } return z; } @Override // java.util.AbstractCollection, java.util.Collection public Object[] toArray() { return Lists.newArrayList(iterator()).toArray(); } @Override // java.util.AbstractCollection, java.util.Collection public T[] toArray(T[] tArr) { return (T[]) Lists.newArrayList(iterator()).toArray(tArr); } } /* loaded from: classes3.dex */ private static class FilteredKeyMap extends AbstractFilteredMap { final Predicate keyPredicate; FilteredKeyMap(Map map, Predicate predicate, Predicate> predicate2) { super(map, predicate2); this.keyPredicate = predicate; } @Override // com.google.common.collect.Maps.ViewCachingAbstractMap protected Set> createEntrySet() { return Sets.filter(this.unfiltered.entrySet(), this.predicate); } @Override // com.google.common.collect.Maps.ViewCachingAbstractMap Set createKeySet() { return Sets.filter(this.unfiltered.keySet(), this.keyPredicate); } @Override // com.google.common.collect.Maps.AbstractFilteredMap, java.util.AbstractMap, java.util.Map public boolean containsKey(@CheckForNull Object obj) { return this.unfiltered.containsKey(obj) && this.keyPredicate.apply(obj); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes3.dex */ public static class FilteredEntryMap extends AbstractFilteredMap { final Set> filteredEntrySet; FilteredEntryMap(Map map, Predicate> predicate) { super(map, predicate); this.filteredEntrySet = Sets.filter(map.entrySet(), this.predicate); } @Override // com.google.common.collect.Maps.ViewCachingAbstractMap protected Set> createEntrySet() { return new EntrySet(); } /* loaded from: classes3.dex */ private class EntrySet extends ForwardingSet> { private EntrySet() { } /* JADX INFO: Access modifiers changed from: protected */ @Override // com.google.common.collect.ForwardingSet, com.google.common.collect.ForwardingCollection, com.google.common.collect.ForwardingObject public Set> delegate() { return FilteredEntryMap.this.filteredEntrySet; } @Override // com.google.common.collect.ForwardingCollection, java.util.Collection, java.lang.Iterable, java.util.Set public Iterator> iterator() { return new TransformedIterator, Map.Entry>(FilteredEntryMap.this.filteredEntrySet.iterator()) { // from class: com.google.common.collect.Maps.FilteredEntryMap.EntrySet.1 /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.TransformedIterator public Map.Entry transform(final Map.Entry entry) { return new ForwardingMapEntry() { // from class: com.google.common.collect.Maps.FilteredEntryMap.EntrySet.1.1 /* JADX INFO: Access modifiers changed from: protected */ @Override // com.google.common.collect.ForwardingMapEntry, com.google.common.collect.ForwardingObject public Map.Entry delegate() { return entry; } @Override // com.google.common.collect.ForwardingMapEntry, java.util.Map.Entry @ParametricNullness public V setValue(@ParametricNullness V v) { Preconditions.checkArgument(FilteredEntryMap.this.apply(getKey(), v)); return (V) super.setValue(v); } }; } }; } } @Override // com.google.common.collect.Maps.ViewCachingAbstractMap Set createKeySet() { return new KeySet(); } static boolean removeAllKeys(Map map, Predicate> predicate, Collection collection) { Iterator> it = map.entrySet().iterator(); boolean z = false; while (it.hasNext()) { Map.Entry next = it.next(); if (predicate.apply(next) && collection.contains(next.getKey())) { it.remove(); z = true; } } return z; } static boolean retainAllKeys(Map map, Predicate> predicate, Collection collection) { Iterator> it = map.entrySet().iterator(); boolean z = false; while (it.hasNext()) { Map.Entry next = it.next(); if (predicate.apply(next) && !collection.contains(next.getKey())) { it.remove(); z = true; } } return z; } /* loaded from: classes3.dex */ class KeySet extends KeySet { KeySet() { super(FilteredEntryMap.this); } @Override // com.google.common.collect.Maps.KeySet, java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean remove(@CheckForNull Object obj) { if (!FilteredEntryMap.this.containsKey(obj)) { return false; } FilteredEntryMap.this.unfiltered.remove(obj); return true; } @Override // com.google.common.collect.Sets.ImprovedAbstractSet, java.util.AbstractSet, java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean removeAll(Collection collection) { return FilteredEntryMap.removeAllKeys(FilteredEntryMap.this.unfiltered, FilteredEntryMap.this.predicate, collection); } @Override // com.google.common.collect.Sets.ImprovedAbstractSet, java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean retainAll(Collection collection) { return FilteredEntryMap.retainAllKeys(FilteredEntryMap.this.unfiltered, FilteredEntryMap.this.predicate, collection); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public Object[] toArray() { return Lists.newArrayList(iterator()).toArray(); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public T[] toArray(T[] tArr) { return (T[]) Lists.newArrayList(iterator()).toArray(tArr); } } } /* JADX INFO: Access modifiers changed from: private */ /* loaded from: classes3.dex */ public static class FilteredEntrySortedMap extends FilteredEntryMap implements SortedMap { FilteredEntrySortedMap(SortedMap sortedMap, Predicate> predicate) { super(sortedMap, predicate); } SortedMap sortedMap() { return (SortedMap) this.unfiltered; } @Override // com.google.common.collect.Maps.ViewCachingAbstractMap, java.util.AbstractMap, java.util.Map public SortedSet keySet() { return (SortedSet) super.keySet(); } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.Maps.FilteredEntryMap, com.google.common.collect.Maps.ViewCachingAbstractMap public SortedSet createKeySet() { return new SortedKeySet(); } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes3.dex */ public class SortedKeySet extends FilteredEntryMap.KeySet implements SortedSet { SortedKeySet() { super(); } @Override // java.util.SortedSet @CheckForNull public Comparator comparator() { return FilteredEntrySortedMap.this.sortedMap().comparator(); } @Override // java.util.SortedSet public SortedSet subSet(@ParametricNullness K k, @ParametricNullness K k2) { return (SortedSet) FilteredEntrySortedMap.this.subMap(k, k2).keySet(); } @Override // java.util.SortedSet public SortedSet headSet(@ParametricNullness K k) { return (SortedSet) FilteredEntrySortedMap.this.headMap(k).keySet(); } @Override // java.util.SortedSet public SortedSet tailSet(@ParametricNullness K k) { return (SortedSet) FilteredEntrySortedMap.this.tailMap(k).keySet(); } @Override // java.util.SortedSet @ParametricNullness public K first() { return (K) FilteredEntrySortedMap.this.firstKey(); } @Override // java.util.SortedSet @ParametricNullness public K last() { return (K) FilteredEntrySortedMap.this.lastKey(); } } @Override // java.util.SortedMap @CheckForNull public Comparator comparator() { return sortedMap().comparator(); } @Override // java.util.SortedMap @ParametricNullness public K firstKey() { return keySet().iterator().next(); } /* JADX WARN: Multi-variable type inference failed */ @Override // java.util.SortedMap @ParametricNullness public K lastKey() { SortedMap sortedMap = sortedMap(); while (true) { K lastKey = sortedMap.lastKey(); if (apply(lastKey, NullnessCasts.uncheckedCastNullableTToT(this.unfiltered.get(lastKey)))) { return lastKey; } sortedMap = sortedMap().headMap(lastKey); } } @Override // java.util.SortedMap public SortedMap headMap(@ParametricNullness K k) { return new FilteredEntrySortedMap(sortedMap().headMap(k), this.predicate); } @Override // java.util.SortedMap public SortedMap subMap(@ParametricNullness K k, @ParametricNullness K k2) { return new FilteredEntrySortedMap(sortedMap().subMap(k, k2), this.predicate); } @Override // java.util.SortedMap public SortedMap tailMap(@ParametricNullness K k) { return new FilteredEntrySortedMap(sortedMap().tailMap(k), this.predicate); } } /* JADX INFO: Access modifiers changed from: private */ /* loaded from: classes3.dex */ public static class FilteredEntryNavigableMap extends AbstractNavigableMap { private final Predicate> entryPredicate; private final Map filteredDelegate; private final NavigableMap unfiltered; FilteredEntryNavigableMap(NavigableMap navigableMap, Predicate> predicate) { this.unfiltered = (NavigableMap) Preconditions.checkNotNull(navigableMap); this.entryPredicate = predicate; this.filteredDelegate = new FilteredEntryMap(navigableMap, predicate); } @Override // java.util.SortedMap @CheckForNull public Comparator comparator() { return this.unfiltered.comparator(); } @Override // com.google.common.collect.AbstractNavigableMap, java.util.NavigableMap public NavigableSet navigableKeySet() { return new NavigableKeySet(this) { // from class: com.google.common.collect.Maps.FilteredEntryNavigableMap.1 @Override // com.google.common.collect.Sets.ImprovedAbstractSet, java.util.AbstractSet, java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean removeAll(Collection collection) { return FilteredEntryMap.removeAllKeys(FilteredEntryNavigableMap.this.unfiltered, FilteredEntryNavigableMap.this.entryPredicate, collection); } @Override // com.google.common.collect.Sets.ImprovedAbstractSet, java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean retainAll(Collection collection) { return FilteredEntryMap.retainAllKeys(FilteredEntryNavigableMap.this.unfiltered, FilteredEntryNavigableMap.this.entryPredicate, collection); } }; } @Override // java.util.AbstractMap, java.util.Map, java.util.SortedMap public Collection values() { return new FilteredMapValues(this, this.unfiltered, this.entryPredicate); } @Override // com.google.common.collect.Maps.IteratorBasedAbstractMap Iterator> entryIterator() { return Iterators.filter(this.unfiltered.entrySet().iterator(), this.entryPredicate); } @Override // com.google.common.collect.AbstractNavigableMap Iterator> descendingEntryIterator() { return Iterators.filter(this.unfiltered.descendingMap().entrySet().iterator(), this.entryPredicate); } @Override // com.google.common.collect.Maps.IteratorBasedAbstractMap, java.util.AbstractMap, java.util.Map public int size() { return this.filteredDelegate.size(); } @Override // java.util.AbstractMap, java.util.Map public boolean isEmpty() { return !Iterables.any(this.unfiltered.entrySet(), this.entryPredicate); } @Override // com.google.common.collect.AbstractNavigableMap, java.util.AbstractMap, java.util.Map @CheckForNull public V get(@CheckForNull Object obj) { return this.filteredDelegate.get(obj); } @Override // java.util.AbstractMap, java.util.Map public boolean containsKey(@CheckForNull Object obj) { return this.filteredDelegate.containsKey(obj); } @Override // java.util.AbstractMap, java.util.Map @CheckForNull public V put(@ParametricNullness K k, @ParametricNullness V v) { return this.filteredDelegate.put(k, v); } @Override // java.util.AbstractMap, java.util.Map @CheckForNull public V remove(@CheckForNull Object obj) { return this.filteredDelegate.remove(obj); } @Override // java.util.AbstractMap, java.util.Map public void putAll(Map map) { this.filteredDelegate.putAll(map); } @Override // com.google.common.collect.Maps.IteratorBasedAbstractMap, java.util.AbstractMap, java.util.Map public void clear() { this.filteredDelegate.clear(); } @Override // com.google.common.collect.Maps.IteratorBasedAbstractMap, java.util.AbstractMap, java.util.Map, java.util.SortedMap public Set> entrySet() { return this.filteredDelegate.entrySet(); } @Override // com.google.common.collect.AbstractNavigableMap, java.util.NavigableMap @CheckForNull public Map.Entry pollFirstEntry() { return (Map.Entry) Iterables.removeFirstMatching(this.unfiltered.entrySet(), this.entryPredicate); } @Override // com.google.common.collect.AbstractNavigableMap, java.util.NavigableMap @CheckForNull public Map.Entry pollLastEntry() { return (Map.Entry) Iterables.removeFirstMatching(this.unfiltered.descendingMap().entrySet(), this.entryPredicate); } @Override // com.google.common.collect.AbstractNavigableMap, java.util.NavigableMap public NavigableMap descendingMap() { return Maps.filterEntries((NavigableMap) this.unfiltered.descendingMap(), (Predicate) this.entryPredicate); } @Override // java.util.NavigableMap public NavigableMap subMap(@ParametricNullness K k, boolean z, @ParametricNullness K k2, boolean z2) { return Maps.filterEntries((NavigableMap) this.unfiltered.subMap(k, z, k2, z2), (Predicate) this.entryPredicate); } @Override // java.util.NavigableMap public NavigableMap headMap(@ParametricNullness K k, boolean z) { return Maps.filterEntries((NavigableMap) this.unfiltered.headMap(k, z), (Predicate) this.entryPredicate); } @Override // java.util.NavigableMap public NavigableMap tailMap(@ParametricNullness K k, boolean z) { return Maps.filterEntries((NavigableMap) this.unfiltered.tailMap(k, z), (Predicate) this.entryPredicate); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes3.dex */ public static final class FilteredEntryBiMap extends FilteredEntryMap implements BiMap { private final BiMap inverse; @Override // com.google.common.collect.BiMap public BiMap inverse() { return this.inverse; } private static Predicate> inversePredicate(final Predicate> predicate) { return new Predicate>() { // from class: com.google.common.collect.Maps.FilteredEntryBiMap.1 @Override // com.google.common.base.Predicate public boolean apply(Map.Entry entry) { return Predicate.this.apply(Maps.immutableEntry(entry.getValue(), entry.getKey())); } }; } FilteredEntryBiMap(BiMap biMap, Predicate> predicate) { super(biMap, predicate); this.inverse = new FilteredEntryBiMap(biMap.inverse(), inversePredicate(predicate), this); } private FilteredEntryBiMap(BiMap biMap, Predicate> predicate, BiMap biMap2) { super(biMap, predicate); this.inverse = biMap2; } BiMap unfiltered() { return (BiMap) this.unfiltered; } @Override // com.google.common.collect.BiMap @CheckForNull public V forcePut(@ParametricNullness K k, @ParametricNullness V v) { Preconditions.checkArgument(apply(k, v)); return unfiltered().forcePut(k, v); } @Override // com.google.common.collect.Maps.ViewCachingAbstractMap, java.util.AbstractMap, java.util.Map, com.google.common.collect.BiMap public Set values() { return this.inverse.keySet(); } } /* JADX WARN: Multi-variable type inference failed */ public static NavigableMap unmodifiableNavigableMap(NavigableMap navigableMap) { Preconditions.checkNotNull(navigableMap); return navigableMap instanceof UnmodifiableNavigableMap ? navigableMap : new UnmodifiableNavigableMap(navigableMap); } /* JADX INFO: Access modifiers changed from: private */ @CheckForNull public static Map.Entry unmodifiableOrNull(@CheckForNull Map.Entry entry) { if (entry == null) { return null; } return unmodifiableEntry(entry); } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes3.dex */ public static class UnmodifiableNavigableMap extends ForwardingSortedMap implements NavigableMap, Serializable { private final NavigableMap delegate; @CheckForNull private transient UnmodifiableNavigableMap descendingMap; UnmodifiableNavigableMap(NavigableMap navigableMap) { this.delegate = navigableMap; } UnmodifiableNavigableMap(NavigableMap navigableMap, UnmodifiableNavigableMap unmodifiableNavigableMap) { this.delegate = navigableMap; this.descendingMap = unmodifiableNavigableMap; } /* JADX INFO: Access modifiers changed from: protected */ @Override // com.google.common.collect.ForwardingSortedMap, com.google.common.collect.ForwardingMap, com.google.common.collect.ForwardingObject public SortedMap delegate() { return Collections.unmodifiableSortedMap(this.delegate); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry lowerEntry(@ParametricNullness K k) { return Maps.unmodifiableOrNull(this.delegate.lowerEntry(k)); } @Override // java.util.NavigableMap @CheckForNull public K lowerKey(@ParametricNullness K k) { return this.delegate.lowerKey(k); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry floorEntry(@ParametricNullness K k) { return Maps.unmodifiableOrNull(this.delegate.floorEntry(k)); } @Override // java.util.NavigableMap @CheckForNull public K floorKey(@ParametricNullness K k) { return this.delegate.floorKey(k); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry ceilingEntry(@ParametricNullness K k) { return Maps.unmodifiableOrNull(this.delegate.ceilingEntry(k)); } @Override // java.util.NavigableMap @CheckForNull public K ceilingKey(@ParametricNullness K k) { return this.delegate.ceilingKey(k); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry higherEntry(@ParametricNullness K k) { return Maps.unmodifiableOrNull(this.delegate.higherEntry(k)); } @Override // java.util.NavigableMap @CheckForNull public K higherKey(@ParametricNullness K k) { return this.delegate.higherKey(k); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry firstEntry() { return Maps.unmodifiableOrNull(this.delegate.firstEntry()); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry lastEntry() { return Maps.unmodifiableOrNull(this.delegate.lastEntry()); } @Override // java.util.NavigableMap @CheckForNull public final Map.Entry pollFirstEntry() { throw new UnsupportedOperationException(); } @Override // java.util.NavigableMap @CheckForNull public final Map.Entry pollLastEntry() { throw new UnsupportedOperationException(); } @Override // java.util.NavigableMap public NavigableMap descendingMap() { UnmodifiableNavigableMap unmodifiableNavigableMap = this.descendingMap; if (unmodifiableNavigableMap != null) { return unmodifiableNavigableMap; } UnmodifiableNavigableMap unmodifiableNavigableMap2 = new UnmodifiableNavigableMap<>(this.delegate.descendingMap(), this); this.descendingMap = unmodifiableNavigableMap2; return unmodifiableNavigableMap2; } @Override // com.google.common.collect.ForwardingMap, java.util.Map public Set keySet() { return navigableKeySet(); } @Override // java.util.NavigableMap public NavigableSet navigableKeySet() { return Sets.unmodifiableNavigableSet(this.delegate.navigableKeySet()); } @Override // java.util.NavigableMap public NavigableSet descendingKeySet() { return Sets.unmodifiableNavigableSet(this.delegate.descendingKeySet()); } @Override // com.google.common.collect.ForwardingSortedMap, java.util.SortedMap public SortedMap subMap(@ParametricNullness K k, @ParametricNullness K k2) { return subMap(k, true, k2, false); } @Override // java.util.NavigableMap public NavigableMap subMap(@ParametricNullness K k, boolean z, @ParametricNullness K k2, boolean z2) { return Maps.unmodifiableNavigableMap(this.delegate.subMap(k, z, k2, z2)); } @Override // com.google.common.collect.ForwardingSortedMap, java.util.SortedMap public SortedMap headMap(@ParametricNullness K k) { return headMap(k, false); } @Override // java.util.NavigableMap public NavigableMap headMap(@ParametricNullness K k, boolean z) { return Maps.unmodifiableNavigableMap(this.delegate.headMap(k, z)); } @Override // com.google.common.collect.ForwardingSortedMap, java.util.SortedMap public SortedMap tailMap(@ParametricNullness K k) { return tailMap(k, true); } @Override // java.util.NavigableMap public NavigableMap tailMap(@ParametricNullness K k, boolean z) { return Maps.unmodifiableNavigableMap(this.delegate.tailMap(k, z)); } } public static NavigableMap synchronizedNavigableMap(NavigableMap navigableMap) { return Synchronized.navigableMap(navigableMap); } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes3.dex */ public static abstract class ViewCachingAbstractMap extends AbstractMap { @CheckForNull private transient Set> entrySet; @CheckForNull private transient Set keySet; @CheckForNull private transient Collection values; abstract Set> createEntrySet(); @Override // java.util.AbstractMap, java.util.Map public Set> entrySet() { Set> set = this.entrySet; if (set != null) { return set; } Set> createEntrySet = createEntrySet(); this.entrySet = createEntrySet; return createEntrySet; } @Override // java.util.AbstractMap, java.util.Map public Set keySet() { Set set = this.keySet; if (set != null) { return set; } Set createKeySet = createKeySet(); this.keySet = createKeySet; return createKeySet; } Set createKeySet() { return new KeySet(this); } @Override // java.util.AbstractMap, java.util.Map, com.google.common.collect.BiMap public Collection values() { Collection collection = this.values; if (collection != null) { return collection; } Collection createValues = createValues(); this.values = createValues; return createValues; } Collection createValues() { return new Values(this); } } /* loaded from: classes3.dex */ static abstract class IteratorBasedAbstractMap extends AbstractMap { /* JADX INFO: Access modifiers changed from: package-private */ public abstract Iterator> entryIterator(); @Override // java.util.AbstractMap, java.util.Map public abstract int size(); @Override // java.util.AbstractMap, java.util.Map, java.util.SortedMap public Set> entrySet() { return new EntrySet() { // from class: com.google.common.collect.Maps.IteratorBasedAbstractMap.1 @Override // com.google.common.collect.Maps.EntrySet Map map() { return IteratorBasedAbstractMap.this; } @Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set public Iterator> iterator() { return IteratorBasedAbstractMap.this.entryIterator(); } }; } @Override // java.util.AbstractMap, java.util.Map public void clear() { Iterators.clear(entryIterator()); } } /* JADX INFO: Access modifiers changed from: package-private */ @CheckForNull public static V safeGet(Map map, @CheckForNull Object obj) { Preconditions.checkNotNull(map); try { return map.get(obj); } catch (ClassCastException | NullPointerException unused) { return null; } } /* JADX INFO: Access modifiers changed from: package-private */ public static boolean safeContainsKey(Map map, @CheckForNull Object obj) { Preconditions.checkNotNull(map); try { return map.containsKey(obj); } catch (ClassCastException | NullPointerException unused) { return false; } } /* JADX INFO: Access modifiers changed from: package-private */ @CheckForNull public static V safeRemove(Map map, @CheckForNull Object obj) { Preconditions.checkNotNull(map); try { return map.remove(obj); } catch (ClassCastException | NullPointerException unused) { return null; } } /* JADX INFO: Access modifiers changed from: package-private */ public static boolean containsKeyImpl(Map map, @CheckForNull Object obj) { return Iterators.contains(keyIterator(map.entrySet().iterator()), obj); } /* JADX INFO: Access modifiers changed from: package-private */ public static boolean containsValueImpl(Map map, @CheckForNull Object obj) { return Iterators.contains(valueIterator(map.entrySet().iterator()), obj); } /* JADX INFO: Access modifiers changed from: package-private */ public static boolean containsEntryImpl(Collection> collection, @CheckForNull Object obj) { if (obj instanceof Map.Entry) { return collection.contains(unmodifiableEntry((Map.Entry) obj)); } return false; } /* JADX INFO: Access modifiers changed from: package-private */ public static boolean removeEntryImpl(Collection> collection, @CheckForNull Object obj) { if (obj instanceof Map.Entry) { return collection.remove(unmodifiableEntry((Map.Entry) obj)); } return false; } /* JADX INFO: Access modifiers changed from: package-private */ public static boolean equalsImpl(Map map, @CheckForNull Object obj) { if (map == obj) { return true; } if (obj instanceof Map) { return map.entrySet().equals(((Map) obj).entrySet()); } return false; } /* JADX INFO: Access modifiers changed from: package-private */ public static String toStringImpl(Map map) { StringBuilder append = Collections2.newStringBuilderForCollection(map.size()).append('{'); boolean z = true; for (Map.Entry entry : map.entrySet()) { if (!z) { append.append(", "); } append.append(entry.getKey()).append('=').append(entry.getValue()); z = false; } return append.append('}').toString(); } /* JADX INFO: Access modifiers changed from: package-private */ public static void putAllImpl(Map map, Map map2) { for (Map.Entry entry : map2.entrySet()) { map.put(entry.getKey(), entry.getValue()); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes3.dex */ public static class KeySet extends Sets.ImprovedAbstractSet { final Map map; /* JADX INFO: Access modifiers changed from: package-private */ public Map map() { return this.map; } /* JADX INFO: Access modifiers changed from: package-private */ public KeySet(Map map) { this.map = (Map) Preconditions.checkNotNull(map); } @Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set public Iterator iterator() { return Maps.keyIterator(map().entrySet().iterator()); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public int size() { return map().size(); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean isEmpty() { return map().isEmpty(); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean contains(@CheckForNull Object obj) { return map().containsKey(obj); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean remove(@CheckForNull Object obj) { if (!contains(obj)) { return false; } map().remove(obj); return true; } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public void clear() { map().clear(); } } /* JADX INFO: Access modifiers changed from: package-private */ @CheckForNull public static K keyOrNull(@CheckForNull Map.Entry entry) { if (entry == null) { return null; } return entry.getKey(); } /* JADX INFO: Access modifiers changed from: package-private */ @CheckForNull public static V valueOrNull(@CheckForNull Map.Entry entry) { if (entry == null) { return null; } return entry.getValue(); } /* loaded from: classes3.dex */ static class SortedKeySet extends KeySet implements SortedSet { /* JADX INFO: Access modifiers changed from: package-private */ public SortedKeySet(SortedMap sortedMap) { super(sortedMap); } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.Maps.KeySet public SortedMap map() { return (SortedMap) super.map(); } @Override // java.util.SortedSet @CheckForNull public Comparator comparator() { return map().comparator(); } public SortedSet subSet(@ParametricNullness K k, @ParametricNullness K k2) { return new SortedKeySet(map().subMap(k, k2)); } public SortedSet headSet(@ParametricNullness K k) { return new SortedKeySet(map().headMap(k)); } public SortedSet tailSet(@ParametricNullness K k) { return new SortedKeySet(map().tailMap(k)); } @Override // java.util.SortedSet @ParametricNullness public K first() { return map().firstKey(); } @Override // java.util.SortedSet @ParametricNullness public K last() { return map().lastKey(); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes3.dex */ public static class NavigableKeySet extends SortedKeySet implements NavigableSet { /* JADX INFO: Access modifiers changed from: package-private */ public NavigableKeySet(NavigableMap navigableMap) { super(navigableMap); } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.Maps.SortedKeySet, com.google.common.collect.Maps.KeySet public NavigableMap map() { return (NavigableMap) this.map; } @Override // java.util.NavigableSet @CheckForNull public K lower(@ParametricNullness K k) { return map().lowerKey(k); } @Override // java.util.NavigableSet @CheckForNull public K floor(@ParametricNullness K k) { return map().floorKey(k); } @Override // java.util.NavigableSet @CheckForNull public K ceiling(@ParametricNullness K k) { return map().ceilingKey(k); } @Override // java.util.NavigableSet @CheckForNull public K higher(@ParametricNullness K k) { return map().higherKey(k); } @Override // java.util.NavigableSet @CheckForNull public K pollFirst() { return (K) Maps.keyOrNull(map().pollFirstEntry()); } @Override // java.util.NavigableSet @CheckForNull public K pollLast() { return (K) Maps.keyOrNull(map().pollLastEntry()); } @Override // java.util.NavigableSet public NavigableSet descendingSet() { return map().descendingKeySet(); } @Override // java.util.NavigableSet public Iterator descendingIterator() { return descendingSet().iterator(); } @Override // java.util.NavigableSet public NavigableSet subSet(@ParametricNullness K k, boolean z, @ParametricNullness K k2, boolean z2) { return map().subMap(k, z, k2, z2).navigableKeySet(); } @Override // com.google.common.collect.Maps.SortedKeySet, java.util.SortedSet, java.util.NavigableSet public SortedSet subSet(@ParametricNullness K k, @ParametricNullness K k2) { return subSet(k, true, k2, false); } @Override // java.util.NavigableSet public NavigableSet headSet(@ParametricNullness K k, boolean z) { return map().headMap(k, z).navigableKeySet(); } @Override // com.google.common.collect.Maps.SortedKeySet, java.util.SortedSet, java.util.NavigableSet public SortedSet headSet(@ParametricNullness K k) { return headSet(k, false); } @Override // java.util.NavigableSet public NavigableSet tailSet(@ParametricNullness K k, boolean z) { return map().tailMap(k, z).navigableKeySet(); } @Override // com.google.common.collect.Maps.SortedKeySet, java.util.SortedSet, java.util.NavigableSet public SortedSet tailSet(@ParametricNullness K k) { return tailSet(k, true); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes3.dex */ public static class Values extends AbstractCollection { final Map map; final Map map() { return this.map; } /* JADX INFO: Access modifiers changed from: package-private */ public Values(Map map) { this.map = (Map) Preconditions.checkNotNull(map); } @Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable public Iterator iterator() { return Maps.valueIterator(map().entrySet().iterator()); } @Override // java.util.AbstractCollection, java.util.Collection public boolean remove(@CheckForNull Object obj) { try { return super.remove(obj); } catch (UnsupportedOperationException unused) { for (Map.Entry entry : this.map().entrySet()) { if (Objects.equal(obj, entry.getValue())) { this.map().remove(entry.getKey()); return true; } } return false; } } @Override // java.util.AbstractCollection, java.util.Collection public boolean removeAll(Collection collection) { try { return super.removeAll((Collection) Preconditions.checkNotNull(collection)); } catch (UnsupportedOperationException unused) { HashSet newHashSet = Sets.newHashSet(); for (Map.Entry entry : this.map().entrySet()) { if (collection.contains(entry.getValue())) { newHashSet.add(entry.getKey()); } } return this.map().keySet().removeAll(newHashSet); } } @Override // java.util.AbstractCollection, java.util.Collection public boolean retainAll(Collection collection) { try { return super.retainAll((Collection) Preconditions.checkNotNull(collection)); } catch (UnsupportedOperationException unused) { HashSet newHashSet = Sets.newHashSet(); for (Map.Entry entry : this.map().entrySet()) { if (collection.contains(entry.getValue())) { newHashSet.add(entry.getKey()); } } return this.map().keySet().retainAll(newHashSet); } } @Override // java.util.AbstractCollection, java.util.Collection public int size() { return map().size(); } @Override // java.util.AbstractCollection, java.util.Collection public boolean isEmpty() { return map().isEmpty(); } @Override // java.util.AbstractCollection, java.util.Collection public boolean contains(@CheckForNull Object obj) { return map().containsValue(obj); } @Override // java.util.AbstractCollection, java.util.Collection public void clear() { map().clear(); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes3.dex */ public static abstract class EntrySet extends Sets.ImprovedAbstractSet> { abstract Map map(); @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public int size() { return map().size(); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public void clear() { map().clear(); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean contains(@CheckForNull Object obj) { if (!(obj instanceof Map.Entry)) { return false; } Map.Entry entry = (Map.Entry) obj; Object key = entry.getKey(); Object safeGet = Maps.safeGet(map(), key); if (Objects.equal(safeGet, entry.getValue())) { return safeGet != null || map().containsKey(key); } return false; } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean isEmpty() { return map().isEmpty(); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean remove(@CheckForNull Object obj) { if (contains(obj) && (obj instanceof Map.Entry)) { return map().keySet().remove(((Map.Entry) obj).getKey()); } return false; } @Override // com.google.common.collect.Sets.ImprovedAbstractSet, java.util.AbstractSet, java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean removeAll(Collection collection) { try { return super.removeAll((Collection) Preconditions.checkNotNull(collection)); } catch (UnsupportedOperationException unused) { return Sets.removeAllImpl(this, collection.iterator()); } } @Override // com.google.common.collect.Sets.ImprovedAbstractSet, java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean retainAll(Collection collection) { try { return super.retainAll((Collection) Preconditions.checkNotNull(collection)); } catch (UnsupportedOperationException unused) { HashSet newHashSetWithExpectedSize = Sets.newHashSetWithExpectedSize(collection.size()); for (Object obj : collection) { if (this.contains(obj) && (obj instanceof Map.Entry)) { newHashSetWithExpectedSize.add(((Map.Entry) obj).getKey()); } } return this.map().keySet().retainAll(newHashSetWithExpectedSize); } } } /* loaded from: classes3.dex */ static abstract class DescendingMap extends ForwardingMap implements NavigableMap { @CheckForNull private transient Comparator comparator; @CheckForNull private transient Set> entrySet; @CheckForNull private transient NavigableSet navigableKeySet; abstract Iterator> entryIterator(); abstract NavigableMap forward(); /* JADX INFO: Access modifiers changed from: protected */ @Override // com.google.common.collect.ForwardingMap, com.google.common.collect.ForwardingObject public final Map delegate() { return forward(); } @Override // java.util.SortedMap public Comparator comparator() { Comparator comparator = this.comparator; if (comparator != null) { return comparator; } Comparator comparator2 = forward().comparator(); if (comparator2 == null) { comparator2 = Ordering.natural(); } Ordering reverse = reverse(comparator2); this.comparator = reverse; return reverse; } private static Ordering reverse(Comparator comparator) { return Ordering.from(comparator).reverse(); } @Override // java.util.SortedMap @ParametricNullness public K firstKey() { return forward().lastKey(); } @Override // java.util.SortedMap @ParametricNullness public K lastKey() { return forward().firstKey(); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry lowerEntry(@ParametricNullness K k) { return forward().higherEntry(k); } @Override // java.util.NavigableMap @CheckForNull public K lowerKey(@ParametricNullness K k) { return forward().higherKey(k); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry floorEntry(@ParametricNullness K k) { return forward().ceilingEntry(k); } @Override // java.util.NavigableMap @CheckForNull public K floorKey(@ParametricNullness K k) { return forward().ceilingKey(k); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry ceilingEntry(@ParametricNullness K k) { return forward().floorEntry(k); } @Override // java.util.NavigableMap @CheckForNull public K ceilingKey(@ParametricNullness K k) { return forward().floorKey(k); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry higherEntry(@ParametricNullness K k) { return forward().lowerEntry(k); } @Override // java.util.NavigableMap @CheckForNull public K higherKey(@ParametricNullness K k) { return forward().lowerKey(k); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry firstEntry() { return forward().lastEntry(); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry lastEntry() { return forward().firstEntry(); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry pollFirstEntry() { return forward().pollLastEntry(); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry pollLastEntry() { return forward().pollFirstEntry(); } @Override // java.util.NavigableMap public NavigableMap descendingMap() { return forward(); } @Override // com.google.common.collect.ForwardingMap, java.util.Map public Set> entrySet() { Set> set = this.entrySet; if (set != null) { return set; } Set> createEntrySet = createEntrySet(); this.entrySet = createEntrySet; return createEntrySet; } Set> createEntrySet() { return new EntrySet() { // from class: com.google.common.collect.Maps.DescendingMap.1EntrySetImpl @Override // com.google.common.collect.Maps.EntrySet Map map() { return DescendingMap.this; } @Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set public Iterator> iterator() { return DescendingMap.this.entryIterator(); } }; } @Override // com.google.common.collect.ForwardingMap, java.util.Map public Set keySet() { return navigableKeySet(); } @Override // java.util.NavigableMap public NavigableSet navigableKeySet() { NavigableSet navigableSet = this.navigableKeySet; if (navigableSet != null) { return navigableSet; } NavigableKeySet navigableKeySet = new NavigableKeySet(this); this.navigableKeySet = navigableKeySet; return navigableKeySet; } @Override // java.util.NavigableMap public NavigableSet descendingKeySet() { return forward().navigableKeySet(); } @Override // java.util.NavigableMap public NavigableMap subMap(@ParametricNullness K k, boolean z, @ParametricNullness K k2, boolean z2) { return forward().subMap(k2, z2, k, z).descendingMap(); } @Override // java.util.NavigableMap, java.util.SortedMap public SortedMap subMap(@ParametricNullness K k, @ParametricNullness K k2) { return subMap(k, true, k2, false); } @Override // java.util.NavigableMap public NavigableMap headMap(@ParametricNullness K k, boolean z) { return forward().tailMap(k, z).descendingMap(); } @Override // java.util.NavigableMap, java.util.SortedMap public SortedMap headMap(@ParametricNullness K k) { return headMap(k, false); } @Override // java.util.NavigableMap public NavigableMap tailMap(@ParametricNullness K k, boolean z) { return forward().headMap(k, z).descendingMap(); } @Override // java.util.NavigableMap, java.util.SortedMap public SortedMap tailMap(@ParametricNullness K k) { return tailMap(k, true); } @Override // com.google.common.collect.ForwardingMap, java.util.Map, com.google.common.collect.BiMap public Collection values() { return new Values(this); } @Override // com.google.common.collect.ForwardingObject public String toString() { return standardToString(); } } /* JADX INFO: Access modifiers changed from: package-private */ public static ImmutableMap indexMap(Collection collection) { ImmutableMap.Builder builder = new ImmutableMap.Builder(collection.size()); Iterator it = collection.iterator(); int i = 0; while (it.hasNext()) { builder.put(it.next(), Integer.valueOf(i)); i++; } return builder.buildOrThrow(); } public static , V> NavigableMap subMap(NavigableMap navigableMap, Range range) { if (navigableMap.comparator() != null && navigableMap.comparator() != Ordering.natural() && range.hasLowerBound() && range.hasUpperBound()) { Preconditions.checkArgument(navigableMap.comparator().compare(range.lowerEndpoint(), range.upperEndpoint()) <= 0, "map is using a custom comparator which is inconsistent with the natural ordering."); } if (range.hasLowerBound() && range.hasUpperBound()) { return navigableMap.subMap(range.lowerEndpoint(), range.lowerBoundType() == BoundType.CLOSED, range.upperEndpoint(), range.upperBoundType() == BoundType.CLOSED); } if (range.hasLowerBound()) { return navigableMap.tailMap(range.lowerEndpoint(), range.lowerBoundType() == BoundType.CLOSED); } if (range.hasUpperBound()) { return navigableMap.headMap(range.upperEndpoint(), range.upperBoundType() == BoundType.CLOSED); } return (NavigableMap) Preconditions.checkNotNull(navigableMap); } }