gate.cache.LazyCache Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gate Show documentation
Show all versions of gate Show documentation
A multipurpose java library
package gate.cache;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;
class LazyCache implements Cache
{
private final Supplier supplier;
private final AtomicReference value = new AtomicReference<>();
LazyCache(Supplier supplier)
{
this.supplier = supplier;
}
@Override
public T get()
{
return value.updateAndGet(e -> e != null ? e : supplier.get());
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy