Class Lazy<T>
java.lang.Object
atlantafx.base.util.Lazy<T>
- All Implemented Interfaces:
Supplier<T>
A wrapper around a
Supplier that defers and caches a single computation.
The wrapped value is computed on the first call to get() and
reused on every subsequent call.
If the supplier produces null, the result is indistinguishable
from "not yet computed" — empty() will keep returning true,
and get() will invoke the supplier again on every call.
Instances are compared by identity. Do not override hashCode()
or equals(), as two instances wrapping equivalent suppliers are
not necessarily interchangeable, particularly before initialization.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
supplier
-
value
-
-
Constructor Details
-
Lazy
-
-
Method Details
-
get
-
empty
public boolean empty()Checks whether the wrapped value is absent.Returns
trueboth whenget()has never been called and when the supplier has returnednull— the two cases cannot be distinguished.- Returns:
trueif there is currently no cached value,falseotherwise
-
toString
-