package com.google.common.collect; import com.google.common.base.Function; import com.google.common.base.Preconditions; import com.google.common.base.Predicate; import com.google.common.base.Predicates; import com.google.common.base.Supplier; import com.google.common.collect.AbstractMapBasedMultimap; import com.google.common.collect.AbstractMultimap; import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.Maps; import com.google.common.collect.Multiset; import com.google.common.collect.Multisets; import com.google.common.collect.Sets; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.AbstractCollection; import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.NavigableSet; import java.util.NoSuchElementException; import java.util.Set; import java.util.SortedSet; /* loaded from: classes2.dex */ public final class Multimaps { private Multimaps() { } public static Multimap newMultimap(Map> map, Supplier> supplier) { return new CustomMultimap(map, supplier); } /* loaded from: classes2.dex */ static class CustomMultimap extends AbstractMapBasedMultimap { private static final long serialVersionUID = 0; transient Supplier> factory; CustomMultimap(Map> map, Supplier> supplier) { super(map); this.factory = (Supplier) Preconditions.checkNotNull(supplier); } @Override // com.google.common.collect.AbstractMapBasedMultimap, com.google.common.collect.AbstractMultimap Set createKeySet() { return createMaybeNavigableKeySet(); } @Override // com.google.common.collect.AbstractMapBasedMultimap, com.google.common.collect.AbstractMultimap Map> createAsMap() { return createMaybeNavigableAsMap(); } @Override // com.google.common.collect.AbstractMapBasedMultimap protected Collection createCollection() { return this.factory.get(); } @Override // com.google.common.collect.AbstractMapBasedMultimap Collection unmodifiableCollectionSubclass(Collection collection) { if (collection instanceof NavigableSet) { return Sets.unmodifiableNavigableSet((NavigableSet) collection); } if (collection instanceof SortedSet) { return Collections.unmodifiableSortedSet((SortedSet) collection); } if (collection instanceof Set) { return Collections.unmodifiableSet((Set) collection); } if (collection instanceof List) { return Collections.unmodifiableList((List) collection); } return Collections.unmodifiableCollection(collection); } @Override // com.google.common.collect.AbstractMapBasedMultimap Collection wrapCollection(K k, Collection collection) { if (collection instanceof List) { return wrapList(k, (List) collection, null); } if (collection instanceof NavigableSet) { return new AbstractMapBasedMultimap.WrappedNavigableSet(this, k, (NavigableSet) collection, null); } if (collection instanceof SortedSet) { return new AbstractMapBasedMultimap.WrappedSortedSet(this, k, (SortedSet) collection, null); } if (collection instanceof Set) { return new AbstractMapBasedMultimap.WrappedSet(this, k, (Set) collection); } return new AbstractMapBasedMultimap.WrappedCollection(this, k, collection, null); } private void writeObject(ObjectOutputStream objectOutputStream) throws IOException { objectOutputStream.defaultWriteObject(); objectOutputStream.writeObject(this.factory); objectOutputStream.writeObject(backingMap()); } private void readObject(ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException { objectInputStream.defaultReadObject(); this.factory = (Supplier) objectInputStream.readObject(); setMap((Map) objectInputStream.readObject()); } } public static ListMultimap newListMultimap(Map> map, Supplier> supplier) { return new CustomListMultimap(map, supplier); } /* loaded from: classes2.dex */ static class CustomListMultimap extends AbstractListMultimap { private static final long serialVersionUID = 0; transient Supplier> factory; CustomListMultimap(Map> map, Supplier> supplier) { super(map); this.factory = (Supplier) Preconditions.checkNotNull(supplier); } @Override // com.google.common.collect.AbstractMapBasedMultimap, com.google.common.collect.AbstractMultimap Set createKeySet() { return createMaybeNavigableKeySet(); } @Override // com.google.common.collect.AbstractMapBasedMultimap, com.google.common.collect.AbstractMultimap Map> createAsMap() { return createMaybeNavigableAsMap(); } /* JADX INFO: Access modifiers changed from: protected */ @Override // com.google.common.collect.AbstractListMultimap, com.google.common.collect.AbstractMapBasedMultimap public List createCollection() { return this.factory.get(); } private void writeObject(ObjectOutputStream objectOutputStream) throws IOException { objectOutputStream.defaultWriteObject(); objectOutputStream.writeObject(this.factory); objectOutputStream.writeObject(backingMap()); } private void readObject(ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException { objectInputStream.defaultReadObject(); this.factory = (Supplier) objectInputStream.readObject(); setMap((Map) objectInputStream.readObject()); } } public static SetMultimap newSetMultimap(Map> map, Supplier> supplier) { return new CustomSetMultimap(map, supplier); } /* loaded from: classes2.dex */ static class CustomSetMultimap extends AbstractSetMultimap { private static final long serialVersionUID = 0; transient Supplier> factory; CustomSetMultimap(Map> map, Supplier> supplier) { super(map); this.factory = (Supplier) Preconditions.checkNotNull(supplier); } @Override // com.google.common.collect.AbstractMapBasedMultimap, com.google.common.collect.AbstractMultimap Set createKeySet() { return createMaybeNavigableKeySet(); } @Override // com.google.common.collect.AbstractMapBasedMultimap, com.google.common.collect.AbstractMultimap Map> createAsMap() { return createMaybeNavigableAsMap(); } /* JADX INFO: Access modifiers changed from: protected */ @Override // com.google.common.collect.AbstractSetMultimap, com.google.common.collect.AbstractMapBasedMultimap public Set createCollection() { return this.factory.get(); } @Override // com.google.common.collect.AbstractSetMultimap, com.google.common.collect.AbstractMapBasedMultimap Collection unmodifiableCollectionSubclass(Collection collection) { if (collection instanceof NavigableSet) { return Sets.unmodifiableNavigableSet((NavigableSet) collection); } if (collection instanceof SortedSet) { return Collections.unmodifiableSortedSet((SortedSet) collection); } return Collections.unmodifiableSet((Set) collection); } @Override // com.google.common.collect.AbstractSetMultimap, com.google.common.collect.AbstractMapBasedMultimap Collection wrapCollection(K k, Collection collection) { if (collection instanceof NavigableSet) { return new AbstractMapBasedMultimap.WrappedNavigableSet(this, k, (NavigableSet) collection, null); } if (collection instanceof SortedSet) { return new AbstractMapBasedMultimap.WrappedSortedSet(this, k, (SortedSet) collection, null); } return new AbstractMapBasedMultimap.WrappedSet(this, k, (Set) collection); } private void writeObject(ObjectOutputStream objectOutputStream) throws IOException { objectOutputStream.defaultWriteObject(); objectOutputStream.writeObject(this.factory); objectOutputStream.writeObject(backingMap()); } private void readObject(ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException { objectInputStream.defaultReadObject(); this.factory = (Supplier) objectInputStream.readObject(); setMap((Map) objectInputStream.readObject()); } } public static SortedSetMultimap newSortedSetMultimap(Map> map, Supplier> supplier) { return new CustomSortedSetMultimap(map, supplier); } /* loaded from: classes2.dex */ static class CustomSortedSetMultimap extends AbstractSortedSetMultimap { private static final long serialVersionUID = 0; transient Supplier> factory; transient Comparator valueComparator; CustomSortedSetMultimap(Map> map, Supplier> supplier) { super(map); this.factory = (Supplier) Preconditions.checkNotNull(supplier); this.valueComparator = supplier.get().comparator(); } @Override // com.google.common.collect.AbstractMapBasedMultimap, com.google.common.collect.AbstractMultimap Set createKeySet() { return createMaybeNavigableKeySet(); } @Override // com.google.common.collect.AbstractMapBasedMultimap, com.google.common.collect.AbstractMultimap Map> createAsMap() { return createMaybeNavigableAsMap(); } /* JADX INFO: Access modifiers changed from: protected */ @Override // com.google.common.collect.AbstractSortedSetMultimap, com.google.common.collect.AbstractSetMultimap, com.google.common.collect.AbstractMapBasedMultimap public SortedSet createCollection() { return this.factory.get(); } private void writeObject(ObjectOutputStream objectOutputStream) throws IOException { objectOutputStream.defaultWriteObject(); objectOutputStream.writeObject(this.factory); objectOutputStream.writeObject(backingMap()); } private void readObject(ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException { objectInputStream.defaultReadObject(); Supplier> supplier = (Supplier) objectInputStream.readObject(); this.factory = supplier; this.valueComparator = supplier.get().comparator(); setMap((Map) objectInputStream.readObject()); } @Override // com.google.common.collect.SortedSetMultimap public Comparator valueComparator() { return this.valueComparator; } } public static > M invertFrom(Multimap multimap, M m) { Preconditions.checkNotNull(m); for (Map.Entry entry : multimap.entries()) { m.put(entry.getValue(), entry.getKey()); } return m; } public static Multimap synchronizedMultimap(Multimap multimap) { return Synchronized.multimap(multimap, null); } public static Multimap unmodifiableMultimap(Multimap multimap) { return ((multimap instanceof UnmodifiableMultimap) || (multimap instanceof ImmutableMultimap)) ? multimap : new UnmodifiableMultimap(multimap); } @Deprecated public static Multimap unmodifiableMultimap(ImmutableMultimap immutableMultimap) { return (Multimap) Preconditions.checkNotNull(immutableMultimap); } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public static class UnmodifiableMultimap extends ForwardingMultimap implements Serializable { private static final long serialVersionUID = 0; final Multimap delegate; transient Collection> entries; transient Set keySet; transient Multiset keys; transient Map> map; transient Collection values; UnmodifiableMultimap(Multimap multimap) { this.delegate = (Multimap) Preconditions.checkNotNull(multimap); } @Override // com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap public void clear() { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap, com.google.common.collect.ListMultimap public Map> asMap() { Map> map = this.map; if (map != null) { return map; } Map> unmodifiableMap = Collections.unmodifiableMap(Maps.transformValues(this.delegate.asMap(), new Function, Collection>(this) { // from class: com.google.common.collect.Multimaps.UnmodifiableMultimap.1 @Override // com.google.common.base.Function public Collection apply(Collection collection) { return Multimaps.unmodifiableValueCollection(collection); } })); this.map = unmodifiableMap; return unmodifiableMap; } @Override // com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap public Collection> entries() { Collection> collection = this.entries; if (collection != null) { return collection; } Collection> unmodifiableEntries = Multimaps.unmodifiableEntries(this.delegate.entries()); this.entries = unmodifiableEntries; return unmodifiableEntries; } @Override // com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap public Collection get(K k) { return Multimaps.unmodifiableValueCollection(this.delegate.get(k)); } @Override // com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap public Multiset keys() { Multiset multiset = this.keys; if (multiset != null) { return multiset; } Multiset unmodifiableMultiset = Multisets.unmodifiableMultiset(this.delegate.keys()); this.keys = unmodifiableMultiset; return unmodifiableMultiset; } @Override // com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap public Set keySet() { Set set = this.keySet; if (set != null) { return set; } Set unmodifiableSet = Collections.unmodifiableSet(this.delegate.keySet()); this.keySet = unmodifiableSet; return unmodifiableSet; } @Override // com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap public boolean put(K k, V v) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap public boolean putAll(K k, Iterable iterable) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap public boolean putAll(Multimap multimap) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap public boolean remove(Object obj, Object obj2) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap public Collection removeAll(Object obj) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap public Collection replaceValues(K k, Iterable iterable) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap public Collection values() { Collection collection = this.values; if (collection != null) { return collection; } Collection unmodifiableCollection = Collections.unmodifiableCollection(this.delegate.values()); this.values = unmodifiableCollection; return unmodifiableCollection; } /* JADX INFO: Access modifiers changed from: protected */ @Override // com.google.common.collect.ForwardingMultimap, com.google.common.collect.ForwardingObject public Multimap delegate() { return this.delegate; } } /* loaded from: classes2.dex */ static class UnmodifiableListMultimap extends UnmodifiableMultimap implements ListMultimap { private static final long serialVersionUID = 0; /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap public /* bridge */ /* synthetic */ Collection get(Object obj) { return get((UnmodifiableListMultimap) obj); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap public /* bridge */ /* synthetic */ Collection replaceValues(Object obj, Iterable iterable) { return replaceValues((UnmodifiableListMultimap) obj, iterable); } UnmodifiableListMultimap(ListMultimap listMultimap) { super(listMultimap); } @Override // com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.ForwardingObject public ListMultimap delegate() { return (ListMultimap) super.delegate(); } @Override // com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap public List get(K k) { return Collections.unmodifiableList(delegate().get((ListMultimap) k)); } @Override // com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap public List removeAll(Object obj) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap public List replaceValues(K k, Iterable iterable) { throw new UnsupportedOperationException(); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public static class UnmodifiableSetMultimap extends UnmodifiableMultimap implements SetMultimap { private static final long serialVersionUID = 0; /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap public /* bridge */ /* synthetic */ Collection get(Object obj) { return get((UnmodifiableSetMultimap) obj); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap public /* bridge */ /* synthetic */ Collection replaceValues(Object obj, Iterable iterable) { return replaceValues((UnmodifiableSetMultimap) obj, iterable); } UnmodifiableSetMultimap(SetMultimap setMultimap) { super(setMultimap); } @Override // com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.ForwardingObject public SetMultimap delegate() { return (SetMultimap) super.delegate(); } @Override // com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap public Set get(K k) { return Collections.unmodifiableSet(delegate().get((SetMultimap) k)); } @Override // com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap public Set> entries() { return Maps.unmodifiableEntrySet(delegate().entries()); } @Override // com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap public Set removeAll(Object obj) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap public Set replaceValues(K k, Iterable iterable) { throw new UnsupportedOperationException(); } } /* loaded from: classes2.dex */ static class UnmodifiableSortedSetMultimap extends UnmodifiableSetMultimap implements SortedSetMultimap { private static final long serialVersionUID = 0; /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.Multimaps.UnmodifiableSetMultimap, com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap public /* bridge */ /* synthetic */ Collection get(Object obj) { return get((UnmodifiableSortedSetMultimap) obj); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.Multimaps.UnmodifiableSetMultimap, com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap public /* bridge */ /* synthetic */ Set get(Object obj) { return get((UnmodifiableSortedSetMultimap) obj); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.Multimaps.UnmodifiableSetMultimap, com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap public /* bridge */ /* synthetic */ Collection replaceValues(Object obj, Iterable iterable) { return replaceValues((UnmodifiableSortedSetMultimap) obj, iterable); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.Multimaps.UnmodifiableSetMultimap, com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap public /* bridge */ /* synthetic */ Set replaceValues(Object obj, Iterable iterable) { return replaceValues((UnmodifiableSortedSetMultimap) obj, iterable); } UnmodifiableSortedSetMultimap(SortedSetMultimap sortedSetMultimap) { super(sortedSetMultimap); } @Override // com.google.common.collect.Multimaps.UnmodifiableSetMultimap, com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.ForwardingObject public SortedSetMultimap delegate() { return (SortedSetMultimap) super.delegate(); } @Override // com.google.common.collect.Multimaps.UnmodifiableSetMultimap, com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap public SortedSet get(K k) { return Collections.unmodifiableSortedSet(delegate().get((SortedSetMultimap) k)); } @Override // com.google.common.collect.Multimaps.UnmodifiableSetMultimap, com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap public SortedSet removeAll(Object obj) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.Multimaps.UnmodifiableSetMultimap, com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap public SortedSet replaceValues(K k, Iterable iterable) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.SortedSetMultimap public Comparator valueComparator() { return delegate().valueComparator(); } } public static SetMultimap synchronizedSetMultimap(SetMultimap setMultimap) { return Synchronized.setMultimap(setMultimap, null); } public static SetMultimap unmodifiableSetMultimap(SetMultimap setMultimap) { return ((setMultimap instanceof UnmodifiableSetMultimap) || (setMultimap instanceof ImmutableSetMultimap)) ? setMultimap : new UnmodifiableSetMultimap(setMultimap); } @Deprecated public static SetMultimap unmodifiableSetMultimap(ImmutableSetMultimap immutableSetMultimap) { return (SetMultimap) Preconditions.checkNotNull(immutableSetMultimap); } public static SortedSetMultimap synchronizedSortedSetMultimap(SortedSetMultimap sortedSetMultimap) { return Synchronized.sortedSetMultimap(sortedSetMultimap, null); } public static SortedSetMultimap unmodifiableSortedSetMultimap(SortedSetMultimap sortedSetMultimap) { return sortedSetMultimap instanceof UnmodifiableSortedSetMultimap ? sortedSetMultimap : new UnmodifiableSortedSetMultimap(sortedSetMultimap); } public static ListMultimap synchronizedListMultimap(ListMultimap listMultimap) { return Synchronized.listMultimap(listMultimap, null); } public static ListMultimap unmodifiableListMultimap(ListMultimap listMultimap) { return ((listMultimap instanceof UnmodifiableListMultimap) || (listMultimap instanceof ImmutableListMultimap)) ? listMultimap : new UnmodifiableListMultimap(listMultimap); } @Deprecated public static ListMultimap unmodifiableListMultimap(ImmutableListMultimap immutableListMultimap) { return (ListMultimap) Preconditions.checkNotNull(immutableListMultimap); } /* JADX INFO: Access modifiers changed from: private */ public static Collection unmodifiableValueCollection(Collection collection) { if (collection instanceof SortedSet) { return Collections.unmodifiableSortedSet((SortedSet) collection); } if (collection instanceof Set) { return Collections.unmodifiableSet((Set) collection); } if (collection instanceof List) { return Collections.unmodifiableList((List) collection); } return Collections.unmodifiableCollection(collection); } /* JADX INFO: Access modifiers changed from: private */ public static Collection> unmodifiableEntries(Collection> collection) { if (collection instanceof Set) { return Maps.unmodifiableEntrySet((Set) collection); } return new Maps.UnmodifiableEntries(Collections.unmodifiableCollection(collection)); } public static Map> asMap(ListMultimap listMultimap) { return listMultimap.asMap(); } public static Map> asMap(SetMultimap setMultimap) { return setMultimap.asMap(); } public static Map> asMap(SortedSetMultimap sortedSetMultimap) { return sortedSetMultimap.asMap(); } public static Map> asMap(Multimap multimap) { return multimap.asMap(); } public static SetMultimap forMap(Map map) { return new MapMultimap(map); } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public static class MapMultimap extends AbstractMultimap implements SetMultimap, Serializable { private static final long serialVersionUID = 7845222491160860175L; final Map map; /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.Multimap public /* bridge */ /* synthetic */ Collection get(Object obj) { return get((MapMultimap) obj); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap public /* bridge */ /* synthetic */ Collection replaceValues(Object obj, Iterable iterable) { return replaceValues((MapMultimap) obj, iterable); } MapMultimap(Map map) { this.map = (Map) Preconditions.checkNotNull(map); } @Override // com.google.common.collect.Multimap public int size() { return this.map.size(); } @Override // com.google.common.collect.Multimap public boolean containsKey(Object obj) { return this.map.containsKey(obj); } @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap public boolean containsValue(Object obj) { return this.map.containsValue(obj); } @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap public boolean containsEntry(Object obj, Object obj2) { return this.map.entrySet().contains(Maps.immutableEntry(obj, obj2)); } /* JADX INFO: Access modifiers changed from: package-private */ /* renamed from: com.google.common.collect.Multimaps$MapMultimap$1, reason: invalid class name */ /* loaded from: classes2.dex */ public class AnonymousClass1 extends Sets.ImprovedAbstractSet { final MapMultimap this$0; final Object val$key; AnonymousClass1(MapMultimap mapMultimap, Object obj) { this.this$0 = mapMultimap; this.val$key = obj; } @Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set public Iterator iterator() { return new Iterator(this) { // from class: com.google.common.collect.Multimaps.MapMultimap.1.1 int i; final AnonymousClass1 this$1; { this.this$1 = this; } @Override // java.util.Iterator public boolean hasNext() { return this.i == 0 && this.this$1.this$0.map.containsKey(this.this$1.val$key); } @Override // java.util.Iterator public V next() { if (!hasNext()) { throw new NoSuchElementException(); } this.i++; return this.this$1.this$0.map.get(this.this$1.val$key); } @Override // java.util.Iterator public void remove() { CollectPreconditions.checkRemove(this.i == 1); this.i = -1; this.this$1.this$0.map.remove(this.this$1.val$key); } }; } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public int size() { return this.this$0.map.containsKey(this.val$key) ? 1 : 0; } } @Override // com.google.common.collect.Multimap public Set get(K k) { return new AnonymousClass1(this, k); } @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap public boolean put(K k, V v) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap public boolean putAll(K k, Iterable iterable) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap public boolean putAll(Multimap multimap) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap public Set replaceValues(K k, Iterable iterable) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap public boolean remove(Object obj, Object obj2) { return this.map.entrySet().remove(Maps.immutableEntry(obj, obj2)); } @Override // com.google.common.collect.Multimap public Set removeAll(Object obj) { HashSet hashSet = new HashSet(2); if (!this.map.containsKey(obj)) { return hashSet; } hashSet.add(this.map.remove(obj)); return hashSet; } @Override // com.google.common.collect.Multimap public void clear() { this.map.clear(); } @Override // com.google.common.collect.AbstractMultimap Set createKeySet() { return this.map.keySet(); } @Override // com.google.common.collect.AbstractMultimap Collection createValues() { return this.map.values(); } @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap public Set> entries() { return this.map.entrySet(); } @Override // com.google.common.collect.AbstractMultimap Collection> createEntries() { throw new AssertionError("unreachable"); } @Override // com.google.common.collect.AbstractMultimap Multiset createKeys() { return new Keys(this); } @Override // com.google.common.collect.AbstractMultimap Iterator> entryIterator() { return this.map.entrySet().iterator(); } @Override // com.google.common.collect.AbstractMultimap Map> createAsMap() { return new AsMap(this); } @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap public int hashCode() { return this.map.hashCode(); } } public static Multimap transformValues(Multimap multimap, Function function) { Preconditions.checkNotNull(function); return transformEntries(multimap, Maps.asEntryTransformer(function)); } public static ListMultimap transformValues(ListMultimap listMultimap, Function function) { Preconditions.checkNotNull(function); return transformEntries((ListMultimap) listMultimap, Maps.asEntryTransformer(function)); } public static Multimap transformEntries(Multimap multimap, Maps.EntryTransformer entryTransformer) { return new TransformedEntriesMultimap(multimap, entryTransformer); } public static ListMultimap transformEntries(ListMultimap listMultimap, Maps.EntryTransformer entryTransformer) { return new TransformedEntriesListMultimap(listMultimap, entryTransformer); } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public static class TransformedEntriesMultimap extends AbstractMultimap { final Multimap fromMultimap; final Maps.EntryTransformer transformer; TransformedEntriesMultimap(Multimap multimap, Maps.EntryTransformer entryTransformer) { this.fromMultimap = (Multimap) Preconditions.checkNotNull(multimap); this.transformer = (Maps.EntryTransformer) Preconditions.checkNotNull(entryTransformer); } Collection transform(K k, Collection collection) { Function asValueToValueFunction = Maps.asValueToValueFunction(this.transformer, k); if (collection instanceof List) { return Lists.transform((List) collection, asValueToValueFunction); } return Collections2.transform(collection, asValueToValueFunction); } @Override // com.google.common.collect.AbstractMultimap Map> createAsMap() { return Maps.transformEntries(this.fromMultimap.asMap(), new Maps.EntryTransformer, Collection>(this) { // from class: com.google.common.collect.Multimaps.TransformedEntriesMultimap.1 final TransformedEntriesMultimap this$0; { this.this$0 = this; } @Override // com.google.common.collect.Maps.EntryTransformer public /* bridge */ /* synthetic */ Object transformEntry(Object obj, Object obj2) { return transformEntry((AnonymousClass1) obj, (Collection) obj2); } public Collection transformEntry(K k, Collection collection) { return this.this$0.transform(k, collection); } }); } @Override // com.google.common.collect.Multimap public void clear() { this.fromMultimap.clear(); } @Override // com.google.common.collect.Multimap public boolean containsKey(Object obj) { return this.fromMultimap.containsKey(obj); } @Override // com.google.common.collect.AbstractMultimap Collection> createEntries() { return new AbstractMultimap.Entries(this); } @Override // com.google.common.collect.AbstractMultimap Iterator> entryIterator() { return Iterators.transform(this.fromMultimap.entries().iterator(), Maps.asEntryToEntryFunction(this.transformer)); } @Override // com.google.common.collect.Multimap public Collection get(K k) { return transform(k, this.fromMultimap.get(k)); } @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap public boolean isEmpty() { return this.fromMultimap.isEmpty(); } @Override // com.google.common.collect.AbstractMultimap Set createKeySet() { return this.fromMultimap.keySet(); } @Override // com.google.common.collect.AbstractMultimap Multiset createKeys() { return this.fromMultimap.keys(); } @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap public boolean put(K k, V2 v2) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap public boolean putAll(K k, Iterable iterable) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap public boolean putAll(Multimap multimap) { throw new UnsupportedOperationException(); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap public boolean remove(Object obj, Object obj2) { return get(obj).remove(obj2); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.Multimap public Collection removeAll(Object obj) { return transform(obj, this.fromMultimap.removeAll(obj)); } @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap public Collection replaceValues(K k, Iterable iterable) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.Multimap public int size() { return this.fromMultimap.size(); } @Override // com.google.common.collect.AbstractMultimap Collection createValues() { return Collections2.transform(this.fromMultimap.entries(), Maps.asEntryToValueFunction(this.transformer)); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public static final class TransformedEntriesListMultimap extends TransformedEntriesMultimap implements ListMultimap { /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.Multimaps.TransformedEntriesMultimap, com.google.common.collect.Multimap public final /* bridge */ /* synthetic */ Collection get(Object obj) { return get((TransformedEntriesListMultimap) obj); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.Multimaps.TransformedEntriesMultimap, com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap public final /* bridge */ /* synthetic */ Collection replaceValues(Object obj, Iterable iterable) { return replaceValues((TransformedEntriesListMultimap) obj, iterable); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.Multimaps.TransformedEntriesMultimap final /* bridge */ /* synthetic */ Collection transform(Object obj, Collection collection) { return transform((TransformedEntriesListMultimap) obj, collection); } TransformedEntriesListMultimap(ListMultimap listMultimap, Maps.EntryTransformer entryTransformer) { super(listMultimap, entryTransformer); } @Override // com.google.common.collect.Multimaps.TransformedEntriesMultimap final List transform(K k, Collection collection) { return Lists.transform((List) collection, Maps.asValueToValueFunction(this.transformer, k)); } @Override // com.google.common.collect.Multimaps.TransformedEntriesMultimap, com.google.common.collect.Multimap public final List get(K k) { return transform((TransformedEntriesListMultimap) k, (Collection) this.fromMultimap.get(k)); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.Multimaps.TransformedEntriesMultimap, com.google.common.collect.Multimap public final List removeAll(Object obj) { return transform((TransformedEntriesListMultimap) obj, (Collection) this.fromMultimap.removeAll(obj)); } @Override // com.google.common.collect.Multimaps.TransformedEntriesMultimap, com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap public final List replaceValues(K k, Iterable iterable) { throw new UnsupportedOperationException(); } } public static ImmutableListMultimap index(Iterable iterable, Function function) { return index(iterable.iterator(), function); } public static ImmutableListMultimap index(Iterator it, Function function) { Preconditions.checkNotNull(function); ImmutableListMultimap.Builder builder = ImmutableListMultimap.builder(); while (it.hasNext()) { V next = it.next(); Preconditions.checkNotNull(next, it); builder.put((ImmutableListMultimap.Builder) function.apply(next), (K) next); } return builder.build(); } /* loaded from: classes2.dex */ static class Keys extends AbstractMultiset { final Multimap multimap; /* JADX INFO: Access modifiers changed from: package-private */ public Keys(Multimap multimap) { this.multimap = multimap; } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.AbstractMultiset public Iterator> entryIterator() { return new TransformedIterator>, Multiset.Entry>(this, this.multimap.asMap().entrySet().iterator()) { // from class: com.google.common.collect.Multimaps.Keys.1 /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.TransformedIterator public Multiset.Entry transform(Map.Entry> entry) { return new Multisets.AbstractEntry(this, entry) { // from class: com.google.common.collect.Multimaps.Keys.1.1 final Map.Entry val$backingEntry; { this.val$backingEntry = entry; } @Override // com.google.common.collect.Multiset.Entry public K getElement() { return (K) this.val$backingEntry.getKey(); } @Override // com.google.common.collect.Multiset.Entry public int getCount() { return ((Collection) this.val$backingEntry.getValue()).size(); } }; } }; } @Override // com.google.common.collect.AbstractMultiset int distinctElements() { return this.multimap.asMap().size(); } @Override // java.util.AbstractCollection, java.util.Collection, com.google.common.collect.Multiset public int size() { return this.multimap.size(); } @Override // com.google.common.collect.AbstractMultiset, java.util.AbstractCollection, java.util.Collection, com.google.common.collect.Multiset public boolean contains(Object obj) { return this.multimap.containsKey(obj); } @Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, com.google.common.collect.Multiset public Iterator iterator() { return Maps.keyIterator(this.multimap.entries().iterator()); } @Override // com.google.common.collect.Multiset public int count(Object obj) { Collection collection = (Collection) Maps.safeGet(this.multimap.asMap(), obj); if (collection == null) { return 0; } return collection.size(); } @Override // com.google.common.collect.AbstractMultiset, com.google.common.collect.Multiset public int remove(Object obj, int i) { CollectPreconditions.checkNonnegative(i, "occurrences"); if (i == 0) { return count(obj); } Collection collection = (Collection) Maps.safeGet(this.multimap.asMap(), obj); if (collection == null) { return 0; } int size = collection.size(); if (i >= size) { collection.clear(); } else { Iterator it = collection.iterator(); for (int i2 = 0; i2 < i; i2++) { it.next(); it.remove(); } } return size; } @Override // com.google.common.collect.AbstractMultiset, java.util.AbstractCollection, java.util.Collection public void clear() { this.multimap.clear(); } @Override // com.google.common.collect.AbstractMultiset, com.google.common.collect.Multiset public Set elementSet() { return this.multimap.keySet(); } @Override // com.google.common.collect.AbstractMultiset Iterator elementIterator() { throw new AssertionError("should never be called"); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public static abstract class Entries extends AbstractCollection> { abstract Multimap multimap(); @Override // java.util.AbstractCollection, java.util.Collection public int size() { return multimap().size(); } @Override // java.util.AbstractCollection, java.util.Collection public boolean contains(Object obj) { if (!(obj instanceof Map.Entry)) { return false; } Map.Entry entry = (Map.Entry) obj; return multimap().containsEntry(entry.getKey(), entry.getValue()); } @Override // java.util.AbstractCollection, java.util.Collection public boolean remove(Object obj) { if (!(obj instanceof Map.Entry)) { return false; } Map.Entry entry = (Map.Entry) obj; return multimap().remove(entry.getKey(), entry.getValue()); } @Override // java.util.AbstractCollection, java.util.Collection public void clear() { multimap().clear(); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public static final class AsMap extends Maps.ViewCachingAbstractMap> { private final Multimap multimap; /* JADX INFO: Access modifiers changed from: package-private */ public AsMap(Multimap multimap) { this.multimap = (Multimap) Preconditions.checkNotNull(multimap); } @Override // java.util.AbstractMap, java.util.Map public final int size() { return this.multimap.keySet().size(); } @Override // com.google.common.collect.Maps.ViewCachingAbstractMap protected final Set>> createEntrySet() { return new EntrySet(this); } final void removeValuesForKey(Object obj) { this.multimap.keySet().remove(obj); } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public class EntrySet extends Maps.EntrySet> { final AsMap this$0; EntrySet(AsMap asMap) { this.this$0 = asMap; } @Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set public Iterator>> iterator() { return Maps.asMapEntryIterator(this.this$0.multimap.keySet(), new Function>(this) { // from class: com.google.common.collect.Multimaps.AsMap.EntrySet.1 final EntrySet this$1; { this.this$1 = this; } @Override // com.google.common.base.Function public /* bridge */ /* synthetic */ Object apply(Object obj) { return apply((AnonymousClass1) obj); } @Override // com.google.common.base.Function public Collection apply(K k) { return this.this$1.this$0.multimap.get(k); } }); } @Override // com.google.common.collect.Maps.EntrySet, java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean remove(Object obj) { if (!contains(obj)) { return false; } this.this$0.removeValuesForKey(((Map.Entry) obj).getKey()); return true; } @Override // com.google.common.collect.Maps.EntrySet Map> map() { return this.this$0; } } @Override // java.util.AbstractMap, java.util.Map public final Collection get(Object obj) { if (containsKey(obj)) { return this.multimap.get(obj); } return null; } @Override // java.util.AbstractMap, java.util.Map public final Collection remove(Object obj) { if (containsKey(obj)) { return this.multimap.removeAll(obj); } return null; } @Override // com.google.common.collect.Maps.ViewCachingAbstractMap, java.util.AbstractMap, java.util.Map public final Set keySet() { return this.multimap.keySet(); } @Override // java.util.AbstractMap, java.util.Map public final boolean isEmpty() { return this.multimap.isEmpty(); } @Override // java.util.AbstractMap, java.util.Map public final boolean containsKey(Object obj) { return this.multimap.containsKey(obj); } @Override // java.util.AbstractMap, java.util.Map public final void clear() { this.multimap.clear(); } } public static Multimap filterKeys(Multimap multimap, Predicate predicate) { if (multimap instanceof SetMultimap) { return filterKeys((SetMultimap) multimap, (Predicate) predicate); } if (multimap instanceof ListMultimap) { return filterKeys((ListMultimap) multimap, (Predicate) predicate); } if (multimap instanceof FilteredKeyMultimap) { FilteredKeyMultimap filteredKeyMultimap = (FilteredKeyMultimap) multimap; return new FilteredKeyMultimap(filteredKeyMultimap.unfiltered, Predicates.and(filteredKeyMultimap.keyPredicate, predicate)); } if (multimap instanceof FilteredMultimap) { return filterFiltered((FilteredMultimap) multimap, Maps.keyPredicateOnEntries(predicate)); } return new FilteredKeyMultimap(multimap, predicate); } public static SetMultimap filterKeys(SetMultimap setMultimap, Predicate predicate) { if (setMultimap instanceof FilteredKeySetMultimap) { FilteredKeySetMultimap filteredKeySetMultimap = (FilteredKeySetMultimap) setMultimap; return new FilteredKeySetMultimap(filteredKeySetMultimap.unfiltered(), Predicates.and(filteredKeySetMultimap.keyPredicate, predicate)); } if (setMultimap instanceof FilteredSetMultimap) { return filterFiltered((FilteredSetMultimap) setMultimap, Maps.keyPredicateOnEntries(predicate)); } return new FilteredKeySetMultimap(setMultimap, predicate); } public static ListMultimap filterKeys(ListMultimap listMultimap, Predicate predicate) { if (listMultimap instanceof FilteredKeyListMultimap) { FilteredKeyListMultimap filteredKeyListMultimap = (FilteredKeyListMultimap) listMultimap; return new FilteredKeyListMultimap(filteredKeyListMultimap.unfiltered(), Predicates.and(filteredKeyListMultimap.keyPredicate, predicate)); } return new FilteredKeyListMultimap(listMultimap, predicate); } public static Multimap filterValues(Multimap multimap, Predicate predicate) { return filterEntries(multimap, Maps.valuePredicateOnEntries(predicate)); } public static SetMultimap filterValues(SetMultimap setMultimap, Predicate predicate) { return filterEntries((SetMultimap) setMultimap, Maps.valuePredicateOnEntries(predicate)); } public static Multimap filterEntries(Multimap multimap, Predicate> predicate) { Preconditions.checkNotNull(predicate); if (multimap instanceof SetMultimap) { return filterEntries((SetMultimap) multimap, (Predicate) predicate); } if (multimap instanceof FilteredMultimap) { return filterFiltered((FilteredMultimap) multimap, predicate); } return new FilteredEntryMultimap((Multimap) Preconditions.checkNotNull(multimap), predicate); } public static SetMultimap filterEntries(SetMultimap setMultimap, Predicate> predicate) { Preconditions.checkNotNull(predicate); if (setMultimap instanceof FilteredSetMultimap) { return filterFiltered((FilteredSetMultimap) setMultimap, (Predicate) predicate); } return new FilteredEntrySetMultimap((SetMultimap) Preconditions.checkNotNull(setMultimap), predicate); } private static Multimap filterFiltered(FilteredMultimap filteredMultimap, Predicate> predicate) { return new FilteredEntryMultimap(filteredMultimap.unfiltered(), Predicates.and(filteredMultimap.entryPredicate(), predicate)); } private static SetMultimap filterFiltered(FilteredSetMultimap filteredSetMultimap, Predicate> predicate) { return new FilteredEntrySetMultimap(filteredSetMultimap.unfiltered(), Predicates.and(filteredSetMultimap.entryPredicate(), predicate)); } /* JADX INFO: Access modifiers changed from: package-private */ public static boolean equalsImpl(Multimap multimap, Object obj) { if (obj == multimap) { return true; } if (obj instanceof Multimap) { return multimap.asMap().equals(((Multimap) obj).asMap()); } return false; } }