package com.google.common.collect; import com.google.common.base.Preconditions; import com.google.common.collect.Multimaps; import java.util.AbstractCollection; import java.util.Collection; import java.util.Iterator; import java.util.Map; import java.util.Set; /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public abstract class AbstractMultimap implements Multimap { private transient Map> asMap; private transient Collection> entries; private transient Set keySet; private transient Multiset keys; 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(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(Object obj, Object obj2) { Collection collection = asMap().get(obj); return collection != null && collection.contains(obj2); } @Override // com.google.common.collect.Multimap public boolean remove(Object obj, Object obj2) { Collection collection = asMap().get(obj); return collection != null && collection.remove(obj2); } @Override // com.google.common.collect.Multimap public boolean put(K k, V v) { return get(k).add(v); } @Override // com.google.common.collect.Multimap public boolean putAll(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 public Collection replaceValues(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: classes2.dex */ class Entries extends Multimaps.Entries { final AbstractMultimap this$0; /* JADX INFO: Access modifiers changed from: package-private */ public Entries(AbstractMultimap abstractMultimap) { this.this$0 = abstractMultimap; } @Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable public Iterator> iterator() { return this.this$0.entryIterator(); } @Override // com.google.common.collect.Multimaps.Entries Multimap multimap() { return this.this$0; } } /* loaded from: classes2.dex */ class EntrySet extends Entries implements Set { /* JADX INFO: Access modifiers changed from: package-private */ public EntrySet(AbstractMultimap abstractMultimap) { super(abstractMultimap); } @Override // java.util.Collection, java.util.Set public int hashCode() { return Sets.hashCodeImpl(this); } @Override // java.util.Collection, java.util.Set public boolean equals(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: classes2.dex */ class Values extends AbstractCollection { final AbstractMultimap this$0; /* JADX INFO: Access modifiers changed from: package-private */ public Values(AbstractMultimap abstractMultimap) { this.this$0 = abstractMultimap; } @Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable public Iterator iterator() { return this.this$0.valueIterator(); } @Override // java.util.AbstractCollection, java.util.Collection public int size() { return this.this$0.size(); } @Override // java.util.AbstractCollection, java.util.Collection public boolean contains(Object obj) { return this.this$0.containsValue(obj); } @Override // java.util.AbstractCollection, java.util.Collection public void clear() { this.this$0.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(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(); } }