public abstract class Lazy<E>
extends java.lang.Object
Constructor and Description |
---|
Lazy() |
Modifier and Type | Method and Description |
---|---|
static <E> Lazy<E> |
cache(java.util.function.Supplier<E> fn)
Create a lazy value from the given provider, allowing the value
stored in the lazy to be garbage collected if necessary.
|
protected abstract E |
compute()
Compute the value of this lazy.
|
static <E> Lazy<E> |
from(E definedElement)
Create a degenerate
Lazy , which simply returns the given pre-computed
value. |
E |
get()
Get the value of this
Lazy , computing it if necessary. |
E |
getIfDefined()
Get the value of this
Lazy if it's been initialized, or else
return null. |
abstract boolean |
isCache()
Specify whether this lazy should garbage collect its value if needed,
or whether it should force it to be persistent.
|
boolean |
isGarbageCollected()
Check if this lazy has been garbage collected, if it is a cached value.
|
static <E> Lazy<E> |
of(java.util.function.Supplier<E> fn)
Create a lazy value from the given provider.
|
protected abstract E compute()
public abstract boolean isCache()
public E getIfDefined()
Lazy
if it's been initialized, or else
return null.public boolean isGarbageCollected()
public static <E> Lazy<E> from(E definedElement)
Lazy
, which simply returns the given pre-computed
value.public static <E> Lazy<E> of(java.util.function.Supplier<E> fn)
public static <E> Lazy<E> cache(java.util.function.Supplier<E> fn)