mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-18 20:07:19 +01:00
50 lines
1.3 KiB
Java
50 lines
1.3 KiB
Java
package com.google.firebase.components;
|
|
|
|
import androidx.annotation.VisibleForTesting;
|
|
import com.google.firebase.inject.Provider;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
/* loaded from: classes8.dex */
|
|
public class Lazy<T> implements Provider<T> {
|
|
private static final Object UNINITIALIZED = new Object();
|
|
private volatile Object instance;
|
|
private volatile Provider<T> provider;
|
|
|
|
public Lazy(T t) {
|
|
this.instance = UNINITIALIZED;
|
|
this.instance = t;
|
|
}
|
|
|
|
@Override // com.google.firebase.inject.Provider
|
|
public T get() {
|
|
T t;
|
|
T t2 = (T) this.instance;
|
|
Object obj = UNINITIALIZED;
|
|
if (t2 != obj) {
|
|
return t2;
|
|
}
|
|
synchronized (this) {
|
|
try {
|
|
t = (T) this.instance;
|
|
if (t == obj) {
|
|
t = this.provider.get();
|
|
this.instance = t;
|
|
this.provider = null;
|
|
}
|
|
} catch (Throwable th) {
|
|
throw th;
|
|
}
|
|
}
|
|
return t;
|
|
}
|
|
|
|
@VisibleForTesting
|
|
public boolean isInitialized() {
|
|
return this.instance != UNINITIALIZED;
|
|
}
|
|
|
|
public Lazy(Provider<T> provider) {
|
|
this.instance = UNINITIALIZED;
|
|
this.provider = provider;
|
|
}
|
|
}
|