package com.google.common.cache; import com.google.common.base.Function; import com.google.common.base.Preconditions; import com.google.common.base.Supplier; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFutureTask; import java.io.Serializable; import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.Executor; /* loaded from: classes2.dex */ public abstract class CacheLoader { public abstract V load(K k) throws Exception; public ListenableFuture reload(K k, V v) throws Exception { Preconditions.checkNotNull(k); Preconditions.checkNotNull(v); return Futures.immediateFuture(load(k)); } public Map loadAll(Iterable iterable) throws Exception { throw new UnsupportedLoadingOperationException(); } public static CacheLoader from(Function function) { return new FunctionToCacheLoader(function); } public static CacheLoader from(Supplier supplier) { return new SupplierToCacheLoader(supplier); } /* loaded from: classes2.dex */ static final class FunctionToCacheLoader extends CacheLoader implements Serializable { private static final long serialVersionUID = 0; private final Function computingFunction; public FunctionToCacheLoader(Function function) { this.computingFunction = (Function) Preconditions.checkNotNull(function); } @Override // com.google.common.cache.CacheLoader public final V load(K k) { return (V) this.computingFunction.apply(Preconditions.checkNotNull(k)); } } public static CacheLoader asyncReloading(CacheLoader cacheLoader, Executor executor) { Preconditions.checkNotNull(cacheLoader); Preconditions.checkNotNull(executor); return new AnonymousClass1(cacheLoader, executor); } /* renamed from: com.google.common.cache.CacheLoader$1, reason: invalid class name */ /* loaded from: classes2.dex */ class AnonymousClass1 extends CacheLoader { final Executor val$executor; final CacheLoader val$loader; AnonymousClass1(CacheLoader cacheLoader, Executor executor) { this.val$loader = cacheLoader; this.val$executor = executor; } @Override // com.google.common.cache.CacheLoader public V load(K k) throws Exception { return (V) this.val$loader.load(k); } @Override // com.google.common.cache.CacheLoader public ListenableFuture reload(K k, V v) throws Exception { ListenableFutureTask create = ListenableFutureTask.create(new Callable(this, k, v) { // from class: com.google.common.cache.CacheLoader.1.1 final AnonymousClass1 this$0; final Object val$key; final Object val$oldValue; { this.this$0 = this; this.val$key = k; this.val$oldValue = v; } /* JADX WARN: Multi-variable type inference failed */ @Override // java.util.concurrent.Callable public V call() throws Exception { return this.this$0.val$loader.reload(this.val$key, this.val$oldValue).get(); } }); this.val$executor.execute(create); return create; } @Override // com.google.common.cache.CacheLoader public Map loadAll(Iterable iterable) throws Exception { return this.val$loader.loadAll(iterable); } } /* loaded from: classes2.dex */ static final class SupplierToCacheLoader extends CacheLoader implements Serializable { private static final long serialVersionUID = 0; private final Supplier computingSupplier; public SupplierToCacheLoader(Supplier supplier) { this.computingSupplier = (Supplier) Preconditions.checkNotNull(supplier); } @Override // com.google.common.cache.CacheLoader public final V load(Object obj) { Preconditions.checkNotNull(obj); return this.computingSupplier.get(); } } /* loaded from: classes2.dex */ public static final class UnsupportedLoadingOperationException extends UnsupportedOperationException { UnsupportedLoadingOperationException() { } } /* loaded from: classes2.dex */ public static final class InvalidCacheLoadException extends RuntimeException { public InvalidCacheLoadException(String str) { super(str); } } }