package com.google.common.collect; import com.google.common.base.Preconditions; import com.google.common.collect.Multimaps; import com.google.errorprone.annotations.concurrent.LazyInit; import java.util.AbstractCollection; import java.util.Collection; import java.util.Iterator; import java.util.Map; import java.util.Set; import javax.annotation.CheckForNull; /* JADX INFO: Access modifiers changed from: package-private */ @ElementTypesAreNonnullByDefault /* loaded from: classes3.dex */ public abstract class AbstractMultimap implements Multimap { @CheckForNull @LazyInit private transient Map> asMap; @CheckForNull @LazyInit private transient Collection> entries; @CheckForNull @LazyInit private transient Set keySet; @CheckForNull @LazyInit private transient Multiset keys; @CheckForNull @LazyInit private transient Collection values; abstract Map> createAsMap(); abstract Collection> createEntries(); abstract Set createKeySet(); abstract Multiset createKeys(); abstract Collection createValues(); abstract Iterator> entryIterator(); @Override // com.google.common.collect.Multimap public boolean isEmpty() { return size() == 0; } @Override // com.google.common.collect.Multimap public boolean containsValue(@CheckForNull Object obj) { Iterator> it = asMap().values().iterator(); while (it.hasNext()) { if (it.next().contains(obj)) { return true; } } return false; } @Override // com.google.common.collect.Multimap public boolean containsEntry(@CheckForNull Object obj, @CheckForNull Object obj2) { Collection collection = asMap().get(obj); return collection != null && collection.contains(obj2); } @Override // com.google.common.collect.Multimap public boolean remove(@CheckForNull Object obj, @CheckForNull Object obj2) { Collection collection = asMap().get(obj); return collection != null && collection.remove(obj2); } @Override // com.google.common.collect.Multimap public boolean put(@ParametricNullness K k, @ParametricNullness V v) { return get(k).add(v); } @Override // com.google.common.collect.Multimap public boolean putAll(@ParametricNullness K k, Iterable iterable) { Preconditions.checkNotNull(iterable); if (iterable instanceof Collection) { Collection collection = (Collection) iterable; return !collection.isEmpty() && get(k).addAll(collection); } Iterator it = iterable.iterator(); return it.hasNext() && Iterators.addAll(get(k), it); } @Override // com.google.common.collect.Multimap public boolean putAll(Multimap multimap) { boolean z = false; for (Map.Entry entry : multimap.entries()) { z |= put(entry.getKey(), entry.getValue()); } return z; } @Override // com.google.common.collect.Multimap, com.google.common.collect.ListMultimap public Collection replaceValues(@ParametricNullness K k, Iterable iterable) { Preconditions.checkNotNull(iterable); Collection removeAll = removeAll(k); putAll(k, iterable); return removeAll; } @Override // com.google.common.collect.Multimap public Collection> entries() { Collection> collection = this.entries; if (collection != null) { return collection; } Collection> createEntries = createEntries(); this.entries = createEntries; return createEntries; } /* loaded from: classes3.dex */ class Entries extends Multimaps.Entries { @Override // com.google.common.collect.Multimaps.Entries Multimap multimap() { return AbstractMultimap.this; } /* JADX INFO: Access modifiers changed from: package-private */ public Entries() { } @Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable public Iterator> iterator() { return AbstractMultimap.this.entryIterator(); } } /* loaded from: classes3.dex */ class EntrySet extends AbstractMultimap.Entries implements Set> { /* JADX INFO: Access modifiers changed from: package-private */ public EntrySet(AbstractMultimap abstractMultimap) { super(); } @Override // java.util.Collection, java.util.Set public int hashCode() { return Sets.hashCodeImpl(this); } @Override // java.util.Collection, java.util.Set public boolean equals(@CheckForNull Object obj) { return Sets.equalsImpl(this, obj); } } @Override // com.google.common.collect.Multimap public Set keySet() { Set set = this.keySet; if (set != null) { return set; } Set createKeySet = createKeySet(); this.keySet = createKeySet; return createKeySet; } @Override // com.google.common.collect.Multimap public Multiset keys() { Multiset multiset = this.keys; if (multiset != null) { return multiset; } Multiset createKeys = createKeys(); this.keys = createKeys; return createKeys; } @Override // com.google.common.collect.Multimap public Collection values() { Collection collection = this.values; if (collection != null) { return collection; } Collection createValues = createValues(); this.values = createValues; return createValues; } /* loaded from: classes3.dex */ class Values extends AbstractCollection { /* JADX INFO: Access modifiers changed from: package-private */ public Values() { } @Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable public Iterator iterator() { return AbstractMultimap.this.valueIterator(); } @Override // java.util.AbstractCollection, java.util.Collection public int size() { return AbstractMultimap.this.size(); } @Override // java.util.AbstractCollection, java.util.Collection public boolean contains(@CheckForNull Object obj) { return AbstractMultimap.this.containsValue(obj); } @Override // java.util.AbstractCollection, java.util.Collection public void clear() { AbstractMultimap.this.clear(); } } Iterator valueIterator() { return Maps.valueIterator(entries().iterator()); } @Override // com.google.common.collect.Multimap, com.google.common.collect.ListMultimap public Map> asMap() { Map> map = this.asMap; if (map != null) { return map; } Map> createAsMap = createAsMap(); this.asMap = createAsMap; return createAsMap; } @Override // com.google.common.collect.Multimap, com.google.common.collect.ListMultimap public boolean equals(@CheckForNull Object obj) { return Multimaps.equalsImpl(this, obj); } @Override // com.google.common.collect.Multimap public int hashCode() { return asMap().hashCode(); } public String toString() { return asMap().toString(); } }