what-the-bank/sources/com/google/firebase/components/OptionalProvider.java

111 lines
4.4 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.google.firebase.components;
import com.google.firebase.inject.Deferred;
import com.google.firebase.inject.Provider;
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public class OptionalProvider<T> implements Provider<T>, Deferred<T> {
private volatile Provider<T> delegate;
private Deferred.DeferredHandler<T> handler;
private static final Deferred.DeferredHandler<Object> NOOP_HANDLER = new Deferred.DeferredHandler() { // from class: com.google.firebase.components.OptionalProvider$$ExternalSyntheticLambda0
@Override // com.google.firebase.inject.Deferred.DeferredHandler
public final void handle(Provider provider) {
OptionalProvider.lambda$static$0(provider);
}
};
private static final Provider<Object> EMPTY_PROVIDER = new Provider() { // from class: com.google.firebase.components.OptionalProvider$$ExternalSyntheticLambda1
@Override // com.google.firebase.inject.Provider
public final Object get() {
return OptionalProvider.lambda$static$1();
}
};
/* JADX INFO: Access modifiers changed from: package-private */
public static /* synthetic */ void lambda$static$0(Provider provider) {
}
/* JADX INFO: Access modifiers changed from: package-private */
public static /* synthetic */ Object lambda$static$1() {
return null;
}
private OptionalProvider(Deferred.DeferredHandler<T> deferredHandler, Provider<T> provider) {
this.handler = deferredHandler;
this.delegate = provider;
}
/* JADX INFO: Access modifiers changed from: package-private */
public static <T> OptionalProvider<T> empty() {
return new OptionalProvider<>(NOOP_HANDLER, EMPTY_PROVIDER);
}
/* JADX INFO: Access modifiers changed from: package-private */
public static <T> OptionalProvider<T> of(Provider<T> provider) {
return new OptionalProvider<>(null, provider);
}
@Override // com.google.firebase.inject.Provider
public T get() {
return this.delegate.get();
}
/* JADX INFO: Access modifiers changed from: package-private */
public void set(Provider<T> provider) {
Deferred.DeferredHandler<T> deferredHandler;
if (this.delegate != EMPTY_PROVIDER) {
throw new IllegalStateException("provide() can be called only once.");
}
synchronized (this) {
deferredHandler = this.handler;
this.handler = null;
this.delegate = provider;
}
deferredHandler.handle(provider);
}
@Override // com.google.firebase.inject.Deferred
public void whenAvailable(final Deferred.DeferredHandler<T> deferredHandler) {
Provider<T> provider;
Provider<T> provider2;
Provider<T> provider3 = this.delegate;
Provider<Object> provider4 = EMPTY_PROVIDER;
if (provider3 != provider4) {
deferredHandler.handle(provider3);
return;
}
synchronized (this) {
provider = this.delegate;
if (provider != provider4) {
provider2 = provider;
} else {
final Deferred.DeferredHandler<T> deferredHandler2 = this.handler;
this.handler = new Deferred.DeferredHandler(deferredHandler2, deferredHandler) { // from class: com.google.firebase.components.OptionalProvider$$ExternalSyntheticLambda2
public final Deferred.DeferredHandler f$0;
public final Deferred.DeferredHandler f$1;
@Override // com.google.firebase.inject.Deferred.DeferredHandler
public final void handle(Provider provider5) {
OptionalProvider.lambda$whenAvailable$2(this.f$0, this.f$1, provider5);
}
{
this.f$0 = deferredHandler2;
this.f$1 = deferredHandler;
}
};
provider2 = null;
}
}
if (provider2 != null) {
deferredHandler.handle(provider);
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public static /* synthetic */ void lambda$whenAvailable$2(Deferred.DeferredHandler deferredHandler, Deferred.DeferredHandler deferredHandler2, Provider provider) {
deferredHandler.handle(provider);
deferredHandler2.handle(provider);
}
}