T - The type of the object@ThreadSafe
public abstract class Lazy<T>
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.Object |
lock |
| Constructor and Description |
|---|
Lazy() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract T |
calculate() |
T |
get() |
void |
invalidate()
Invalidate the current value so that it will be recalculated on the next call of
get().This method only sets the initialized flag to false and does not reset the value itself. |
boolean |
isInitialized() |
static <T> Lazy<T> |
of(java.util.function.Supplier<T> supplier)
Create a new lazy object.
|
public static <T> Lazy<T> of(java.util.function.Supplier<T> supplier)
T - The type of the objectsupplier - The supplier to create the objectpublic boolean isInitialized()
public T get()
public void invalidate()
get().initialized flag to false and does not reset the value itself.protected abstract T calculate()