package com.google.common.graph; import com.google.common.base.Preconditions; import java.util.Map; import javax.annotation.CheckForNull; @ElementTypesAreNonnullByDefault /* loaded from: classes3.dex */ final class MapRetrievalCache extends MapIteratorCache { @CheckForNull private volatile transient CacheEntry cacheEntry1; @CheckForNull private volatile transient CacheEntry cacheEntry2; private void addToCache(CacheEntry cacheEntry) { this.cacheEntry2 = this.cacheEntry1; this.cacheEntry1 = cacheEntry; } /* JADX INFO: Access modifiers changed from: package-private */ public MapRetrievalCache(Map map) { super(map); } /* JADX INFO: Access modifiers changed from: package-private */ /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.graph.MapIteratorCache @CheckForNull public V get(Object obj) { Preconditions.checkNotNull(obj); V ifCached = getIfCached(obj); if (ifCached != null) { return ifCached; } V withoutCaching = getWithoutCaching(obj); if (withoutCaching != null) { addToCache(obj, withoutCaching); } return withoutCaching; } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.graph.MapIteratorCache @CheckForNull public V getIfCached(@CheckForNull Object obj) { V v = (V) super.getIfCached(obj); if (v != null) { return v; } CacheEntry cacheEntry = this.cacheEntry1; if (cacheEntry != null && cacheEntry.key == obj) { return cacheEntry.value; } CacheEntry cacheEntry2 = this.cacheEntry2; if (cacheEntry2 == null || cacheEntry2.key != obj) { return null; } addToCache(cacheEntry2); return cacheEntry2.value; } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.graph.MapIteratorCache public void clearCache() { super.clearCache(); this.cacheEntry1 = null; this.cacheEntry2 = null; } private void addToCache(K k, V v) { addToCache(new CacheEntry<>(k, v)); } /* JADX INFO: Access modifiers changed from: private */ /* loaded from: classes3.dex */ public static final class CacheEntry { final K key; final V value; CacheEntry(K k, V v) { this.key = k; this.value = v; } } }