package com.google.common.collect; import com.google.common.base.Preconditions; import com.google.common.collect.Multiset; import com.google.common.collect.Serialization; import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Comparator; import java.util.Iterator; import java.util.Map; import java.util.Set; /* loaded from: classes2.dex */ public abstract class ImmutableMultimap extends BaseImmutableMultimap implements Serializable { private static final long serialVersionUID = 0; final transient ImmutableMap> map; final transient int size; @Override // com.google.common.collect.Multimap public abstract ImmutableCollection get(K k); public abstract ImmutableMultimap inverse(); @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap public /* bridge */ /* synthetic */ boolean containsEntry(Object obj, Object obj2) { return super.containsEntry(obj, obj2); } @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap, com.google.common.collect.ListMultimap public /* bridge */ /* synthetic */ boolean equals(Object obj) { return super.equals(obj); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.Multimap public /* bridge */ /* synthetic */ Collection get(Object obj) { return get((ImmutableMultimap) obj); } @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap public /* bridge */ /* synthetic */ int hashCode() { return super.hashCode(); } @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap public /* bridge */ /* synthetic */ boolean isEmpty() { return super.isEmpty(); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap @Deprecated public /* bridge */ /* synthetic */ Collection replaceValues(Object obj, Iterable iterable) { return replaceValues((ImmutableMultimap) obj, iterable); } @Override // com.google.common.collect.AbstractMultimap public /* bridge */ /* synthetic */ String toString() { return super.toString(); } public static ImmutableMultimap of() { return ImmutableListMultimap.of(); } public static ImmutableMultimap of(K k, V v) { return ImmutableListMultimap.of((Object) k, (Object) v); } public static ImmutableMultimap of(K k, V v, K k2, V v2) { return ImmutableListMultimap.of((Object) k, (Object) v, (Object) k2, (Object) v2); } public static ImmutableMultimap of(K k, V v, K k2, V v2, K k3, V v3) { return ImmutableListMultimap.of((Object) k, (Object) v, (Object) k2, (Object) v2, (Object) k3, (Object) v3); } public static ImmutableMultimap of(K k, V v, K k2, V v2, K k3, V v3, K k4, V v4) { return ImmutableListMultimap.of((Object) k, (Object) v, (Object) k2, (Object) v2, (Object) k3, (Object) v3, (Object) k4, (Object) v4); } public static ImmutableMultimap of(K k, V v, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) { return ImmutableListMultimap.of((Object) k, (Object) v, (Object) k2, (Object) v2, (Object) k3, (Object) v3, (Object) k4, (Object) v4, (Object) k5, (Object) v5); } public static Builder builder() { return new Builder<>(); } /* loaded from: classes2.dex */ public static class Builder { Map> builderMap = Platform.preservesInsertionOrderOnPutsMap(); Comparator keyComparator; Comparator valueComparator; Collection newMutableValueCollection() { return new ArrayList(); } public Builder put(K k, V v) { CollectPreconditions.checkEntryNotNull(k, v); Collection collection = this.builderMap.get(k); if (collection == null) { Map> map = this.builderMap; Collection newMutableValueCollection = newMutableValueCollection(); map.put(k, newMutableValueCollection); collection = newMutableValueCollection; } collection.add(v); return this; } public Builder put(Map.Entry entry) { return put(entry.getKey(), entry.getValue()); } public Builder putAll(Iterable> iterable) { Iterator> it = iterable.iterator(); while (it.hasNext()) { put(it.next()); } return this; } public Builder putAll(K k, Iterable iterable) { if (k == null) { String valueOf = String.valueOf(Iterables.toString(iterable)); throw new NullPointerException(valueOf.length() != 0 ? "null key in entry: null=".concat(valueOf) : new String("null key in entry: null=")); } Collection collection = this.builderMap.get(k); if (collection != null) { for (V v : iterable) { CollectPreconditions.checkEntryNotNull(k, v); collection.add(v); } return this; } Iterator it = iterable.iterator(); if (!it.hasNext()) { return this; } Collection newMutableValueCollection = newMutableValueCollection(); while (it.hasNext()) { V next = it.next(); CollectPreconditions.checkEntryNotNull(k, next); newMutableValueCollection.add(next); } this.builderMap.put(k, newMutableValueCollection); return this; } public Builder putAll(K k, V... vArr) { return putAll((Builder) k, Arrays.asList(vArr)); } public Builder putAll(Multimap multimap) { for (Map.Entry> entry : multimap.asMap().entrySet()) { putAll((Builder) entry.getKey(), entry.getValue()); } return this; } public Builder orderKeysBy(Comparator comparator) { this.keyComparator = (Comparator) Preconditions.checkNotNull(comparator); return this; } public Builder orderValuesBy(Comparator comparator) { this.valueComparator = (Comparator) Preconditions.checkNotNull(comparator); return this; } /* JADX INFO: Access modifiers changed from: package-private */ public Builder combine(Builder builder) { for (Map.Entry> entry : builder.builderMap.entrySet()) { putAll((Builder) entry.getKey(), entry.getValue()); } return this; } public ImmutableMultimap build() { Collection entrySet = this.builderMap.entrySet(); Comparator comparator = this.keyComparator; if (comparator != null) { entrySet = Ordering.from(comparator).onKeys().immutableSortedCopy(entrySet); } return ImmutableListMultimap.fromMapEntries(entrySet, this.valueComparator); } } public static ImmutableMultimap copyOf(Multimap multimap) { if (multimap instanceof ImmutableMultimap) { ImmutableMultimap immutableMultimap = (ImmutableMultimap) multimap; if (!immutableMultimap.isPartialView()) { return immutableMultimap; } } return ImmutableListMultimap.copyOf((Multimap) multimap); } public static ImmutableMultimap copyOf(Iterable> iterable) { return ImmutableListMultimap.copyOf((Iterable) iterable); } /* loaded from: classes2.dex */ static class FieldSettersHolder { static final Serialization.FieldSetter MAP_FIELD_SETTER = Serialization.getFieldSetter(ImmutableMultimap.class, "map"); static final Serialization.FieldSetter SIZE_FIELD_SETTER = Serialization.getFieldSetter(ImmutableMultimap.class, "size"); FieldSettersHolder() { } } /* JADX INFO: Access modifiers changed from: package-private */ public ImmutableMultimap(ImmutableMap> immutableMap, int i) { this.map = immutableMap; this.size = i; } @Override // com.google.common.collect.Multimap @Deprecated public ImmutableCollection removeAll(Object obj) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap @Deprecated public ImmutableCollection replaceValues(K k, Iterable iterable) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.Multimap @Deprecated public void clear() { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap @Deprecated public boolean put(K k, V v) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap @Deprecated public boolean putAll(K k, Iterable iterable) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap @Deprecated public boolean putAll(Multimap multimap) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap @Deprecated public boolean remove(Object obj, Object obj2) { throw new UnsupportedOperationException(); } /* JADX INFO: Access modifiers changed from: package-private */ public boolean isPartialView() { return this.map.isPartialView(); } @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 obj != null && super.containsValue(obj); } @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap public ImmutableSet keySet() { return this.map.keySet(); } @Override // com.google.common.collect.AbstractMultimap Set createKeySet() { throw new AssertionError("unreachable"); } @Override // com.google.common.collect.AbstractMultimap Map> createAsMap() { throw new AssertionError("should never be called"); } @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap public ImmutableCollection> entries() { return (ImmutableCollection) super.entries(); } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.AbstractMultimap public ImmutableCollection> createEntries() { return new EntryCollection(this); } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public static class EntryCollection extends ImmutableCollection> { private static final long serialVersionUID = 0; final ImmutableMultimap multimap; @Override // com.google.common.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set, java.util.NavigableSet, com.google.common.collect.SortedIterable public /* bridge */ /* synthetic */ Iterator iterator() { return iterator(); } EntryCollection(ImmutableMultimap immutableMultimap) { this.multimap = immutableMultimap; } @Override // com.google.common.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set, java.util.NavigableSet, com.google.common.collect.SortedIterable public UnmodifiableIterator> iterator() { return this.multimap.entryIterator(); } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.ImmutableCollection public boolean isPartialView() { return this.multimap.isPartialView(); } @Override // java.util.AbstractCollection, java.util.Collection public int size() { return this.multimap.size(); } @Override // com.google.common.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean contains(Object obj) { if (!(obj instanceof Map.Entry)) { return false; } Map.Entry entry = (Map.Entry) obj; return this.multimap.containsEntry(entry.getKey(), entry.getValue()); } } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.AbstractMultimap public UnmodifiableIterator> entryIterator() { return new UnmodifiableIterator>(this) { // from class: com.google.common.collect.ImmutableMultimap.1 final Iterator>> asMapItr; final ImmutableMultimap this$0; K currentKey = null; Iterator valueItr = Iterators.emptyIterator(); { this.this$0 = this; this.asMapItr = this.map.entrySet().iterator(); } @Override // java.util.Iterator public boolean hasNext() { return this.valueItr.hasNext() || this.asMapItr.hasNext(); } @Override // java.util.Iterator public Map.Entry next() { if (!this.valueItr.hasNext()) { Map.Entry> next = this.asMapItr.next(); this.currentKey = next.getKey(); this.valueItr = next.getValue().iterator(); } return Maps.immutableEntry(this.currentKey, this.valueItr.next()); } }; } @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap public ImmutableMultiset keys() { return (ImmutableMultiset) super.keys(); } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.AbstractMultimap public ImmutableMultiset createKeys() { return new Keys(this); } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public class Keys extends ImmutableMultiset { final ImmutableMultimap this$0; /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.ImmutableCollection public boolean isPartialView() { return true; } @Override // com.google.common.collect.ImmutableMultiset, com.google.common.collect.Multiset public /* bridge */ /* synthetic */ Set elementSet() { return elementSet(); } Keys(ImmutableMultimap immutableMultimap) { this.this$0 = immutableMultimap; } @Override // com.google.common.collect.ImmutableMultiset, com.google.common.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean contains(Object obj) { return this.this$0.containsKey(obj); } @Override // com.google.common.collect.Multiset public int count(Object obj) { ImmutableCollection immutableCollection = this.this$0.map.get(obj); if (immutableCollection == null) { return 0; } return immutableCollection.size(); } @Override // com.google.common.collect.ImmutableMultiset, com.google.common.collect.Multiset public ImmutableSet elementSet() { return this.this$0.keySet(); } @Override // java.util.AbstractCollection, java.util.Collection, com.google.common.collect.Multiset public int size() { return this.this$0.size(); } @Override // com.google.common.collect.ImmutableMultiset Multiset.Entry getEntry(int i) { Map.Entry> entry = this.this$0.map.entrySet().asList().get(i); return Multisets.immutableEntry(entry.getKey(), entry.getValue().size()); } @Override // com.google.common.collect.ImmutableMultiset, com.google.common.collect.ImmutableCollection Object writeReplace() { return new KeysSerializedForm(this.this$0); } } /* loaded from: classes2.dex */ static final class KeysSerializedForm implements Serializable { final ImmutableMultimap multimap; KeysSerializedForm(ImmutableMultimap immutableMultimap) { this.multimap = immutableMultimap; } final Object readResolve() { return this.multimap.keys(); } } @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap public ImmutableCollection values() { return (ImmutableCollection) super.values(); } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.AbstractMultimap public ImmutableCollection createValues() { return new Values(this); } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.AbstractMultimap public UnmodifiableIterator valueIterator() { return new UnmodifiableIterator(this) { // from class: com.google.common.collect.ImmutableMultimap.2 final ImmutableMultimap this$0; Iterator> valueCollectionItr; Iterator valueItr = Iterators.emptyIterator(); { this.this$0 = this; this.valueCollectionItr = this.map.values().iterator(); } @Override // java.util.Iterator public boolean hasNext() { return this.valueItr.hasNext() || this.valueCollectionItr.hasNext(); } @Override // java.util.Iterator public V next() { if (!this.valueItr.hasNext()) { this.valueItr = this.valueCollectionItr.next().iterator(); } return this.valueItr.next(); } }; } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public static final class Values extends ImmutableCollection { private static final long serialVersionUID = 0; private final transient ImmutableMultimap multimap; /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.ImmutableCollection public final boolean isPartialView() { return true; } @Override // com.google.common.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set, java.util.NavigableSet, com.google.common.collect.SortedIterable public final /* bridge */ /* synthetic */ Iterator iterator() { return iterator(); } Values(ImmutableMultimap immutableMultimap) { this.multimap = immutableMultimap; } @Override // com.google.common.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.util.Set public final boolean contains(Object obj) { return this.multimap.containsValue(obj); } @Override // com.google.common.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set, java.util.NavigableSet, com.google.common.collect.SortedIterable public final UnmodifiableIterator iterator() { return this.multimap.valueIterator(); } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.ImmutableCollection public final int copyIntoArray(Object[] objArr, int i) { UnmodifiableIterator> it = this.multimap.map.values().iterator(); while (it.hasNext()) { i = it.next().copyIntoArray(objArr, i); } return i; } @Override // java.util.AbstractCollection, java.util.Collection public final int size() { return this.multimap.size(); } } @Override // com.google.common.collect.Multimap public int size() { return this.size; } @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap, com.google.common.collect.ListMultimap public ImmutableMap> asMap() { return this.map; } }