package com.google.common.collect; import com.google.common.base.Preconditions; import com.google.common.primitives.Primitives; import java.io.Serializable; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; /* loaded from: classes2.dex */ public final class MutableClassToInstanceMap extends ForwardingMap, B> implements ClassToInstanceMap, Serializable { private final Map, B> delegate; /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.ForwardingMap, java.util.Map, com.google.common.collect.BiMap public final /* bridge */ /* synthetic */ Object put(Object obj, Object obj2) { return put((Class>) obj, (Class) obj2); } public static MutableClassToInstanceMap create() { return new MutableClassToInstanceMap<>(new HashMap()); } public static MutableClassToInstanceMap create(Map, B> map) { return new MutableClassToInstanceMap<>(map); } private MutableClassToInstanceMap(Map, B> map) { this.delegate = (Map) Preconditions.checkNotNull(map); } static Map.Entry, B> checkedEntry(Map.Entry, B> entry) { return new ForwardingMapEntry, B>(entry) { // from class: com.google.common.collect.MutableClassToInstanceMap.1 final Map.Entry val$entry; { this.val$entry = entry; } @Override // com.google.common.collect.ForwardingMapEntry, java.util.Map.Entry public B setValue(B b) { return (B) super.setValue(MutableClassToInstanceMap.cast(getKey(), b)); } /* JADX INFO: Access modifiers changed from: protected */ @Override // com.google.common.collect.ForwardingMapEntry, com.google.common.collect.ForwardingObject public Map.Entry, B> delegate() { return this.val$entry; } }; } @Override // com.google.common.collect.ForwardingMap, java.util.Map public final Set, B>> entrySet() { return new ForwardingSet, B>>(this) { // from class: com.google.common.collect.MutableClassToInstanceMap.2 final MutableClassToInstanceMap this$0; { this.this$0 = this; } /* JADX INFO: Access modifiers changed from: protected */ @Override // com.google.common.collect.ForwardingSet, com.google.common.collect.ForwardingCollection, com.google.common.collect.ForwardingObject public Set, B>> delegate() { return this.this$0.delegate().entrySet(); } @Override // com.google.common.collect.ForwardingCollection, java.util.Collection, java.lang.Iterable, java.util.Set public Iterator, B>> iterator() { return new TransformedIterator, B>, Map.Entry, B>>(this, delegate().iterator()) { // from class: com.google.common.collect.MutableClassToInstanceMap.2.1 /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.TransformedIterator public Map.Entry, B> transform(Map.Entry, B> entry) { return MutableClassToInstanceMap.checkedEntry(entry); } }; } @Override // com.google.common.collect.ForwardingCollection, java.util.Collection, java.util.Set public Object[] toArray() { return standardToArray(); } @Override // com.google.common.collect.ForwardingCollection, java.util.Collection, java.util.Set public T[] toArray(T[] tArr) { return (T[]) standardToArray(tArr); } }; } public final B put(Class cls, B b) { return (B) super.put((MutableClassToInstanceMap) cls, (Class) cast(cls, b)); } @Override // com.google.common.collect.ForwardingMap, java.util.Map, com.google.common.collect.BiMap public final void putAll(Map, ? extends B> map) { LinkedHashMap linkedHashMap = new LinkedHashMap(map); for (Map.Entry entry : linkedHashMap.entrySet()) { cast((Class) entry.getKey(), entry.getValue()); } super.putAll(linkedHashMap); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.ClassToInstanceMap public final T putInstance(Class cls, T t) { return (T) cast(cls, put((Class>) cls, (Class) t)); } @Override // com.google.common.collect.ClassToInstanceMap public final T getInstance(Class cls) { return (T) cast(cls, get(cls)); } /* JADX INFO: Access modifiers changed from: private */ public static T cast(Class cls, B b) { return (T) Primitives.wrap(cls).cast(b); } private Object writeReplace() { return new SerializedForm(delegate()); } /* loaded from: classes2.dex */ static final class SerializedForm implements Serializable { private static final long serialVersionUID = 0; private final Map, B> backingMap; SerializedForm(Map, B> map) { this.backingMap = map; } final Object readResolve() { return MutableClassToInstanceMap.create(this.backingMap); } } /* JADX INFO: Access modifiers changed from: protected */ @Override // com.google.common.collect.ForwardingMap, com.google.common.collect.ForwardingObject public final Map, B> delegate() { return this.delegate; } }