package com.google.common.collect; import com.google.common.base.Preconditions; import com.google.common.collect.Multiset; import com.google.common.collect.Serialization; import com.google.errorprone.annotations.DoNotMock; 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.Objects; import java.util.Set; import javax.annotation.CheckForNull; @ElementTypesAreNonnullByDefault /* loaded from: classes3.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.AbstractMultimap, com.google.common.collect.Multimap, com.google.common.collect.ListMultimap public ImmutableMap> asMap() { return this.map; } @Override // com.google.common.collect.Multimap, com.google.common.collect.ListMultimap public abstract ImmutableCollection get(K k); public abstract ImmutableMultimap inverse(); @Override // com.google.common.collect.Multimap public int size() { return this.size; } @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap public /* bridge */ /* synthetic */ boolean containsEntry(@CheckForNull Object obj, @CheckForNull 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(@CheckForNull Object obj) { return super.equals(obj); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.Multimap, com.google.common.collect.ListMultimap 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, com.google.common.collect.ListMultimap @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<>(); } @DoNotMock /* loaded from: classes3.dex */ public static class Builder { final Map> builderMap = Platform.preservesInsertionOrderOnPutsMap(); @CheckForNull Comparator keyComparator; @CheckForNull 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: classes3.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, com.google.common.collect.ListMultimap @Deprecated public ImmutableCollection removeAll(@CheckForNull Object obj) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap, com.google.common.collect.ListMultimap @Deprecated public ImmutableCollection replaceValues(K k, Iterable iterable) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.Multimap @Deprecated public final void clear() { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap @Deprecated public final boolean put(K k, V v) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap @Deprecated public final boolean putAll(K k, Iterable iterable) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap @Deprecated public final boolean putAll(Multimap multimap) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap @Deprecated public final boolean remove(@CheckForNull Object obj, @CheckForNull 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(@CheckForNull Object obj) { return this.map.containsKey(obj); } @Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap public boolean containsValue(@CheckForNull 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: private */ /* loaded from: classes3.dex */ public static class EntryCollection extends ImmutableCollection> { private static final long serialVersionUID = 0; final ImmutableMultimap multimap; 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(@CheckForNull 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>() { // from class: com.google.common.collect.ImmutableMultimap.1 final Iterator>> asMapItr; @CheckForNull K currentKey = null; Iterator valueItr = Iterators.emptyIterator(); { this.asMapItr = ImmutableMultimap.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(Objects.requireNonNull(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(); } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes3.dex */ public class Keys extends ImmutableMultiset { /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.ImmutableCollection public boolean isPartialView() { return true; } Keys() { } @Override // com.google.common.collect.ImmutableMultiset, com.google.common.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean contains(@CheckForNull Object obj) { return ImmutableMultimap.this.containsKey(obj); } @Override // com.google.common.collect.Multiset public int count(@CheckForNull Object obj) { ImmutableCollection immutableCollection = ImmutableMultimap.this.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 ImmutableMultimap.this.keySet(); } @Override // java.util.AbstractCollection, java.util.Collection, com.google.common.collect.Multiset public int size() { return ImmutableMultimap.this.size(); } @Override // com.google.common.collect.ImmutableMultiset Multiset.Entry getEntry(int i) { Map.Entry> entry = ImmutableMultimap.this.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(ImmutableMultimap.this); } } /* loaded from: classes3.dex */ private static final class KeysSerializedForm implements Serializable { final ImmutableMultimap multimap; KeysSerializedForm(ImmutableMultimap immutableMultimap) { this.multimap = immutableMultimap; } 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() { // from class: com.google.common.collect.ImmutableMultimap.2 Iterator> valueCollectionItr; Iterator valueItr = Iterators.emptyIterator(); { this.valueCollectionItr = ImmutableMultimap.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: private */ /* loaded from: classes3.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 boolean isPartialView() { return true; } Values(ImmutableMultimap immutableMultimap) { this.multimap = immutableMultimap; } @Override // com.google.common.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean contains(@CheckForNull 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 UnmodifiableIterator iterator() { return this.multimap.valueIterator(); } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.ImmutableCollection public 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 int size() { return this.multimap.size(); } } }