This class will take a computer function that computes its final result value. The computer function will be called the first time get() is called on this supplier. The computer function is only called once during the lifetime of this object, and its return value will be retained. Any following calls to get() will return the computed object.
Use the static of(...)
methods to create a new instance.
public T | get() Gets a result. |
public T | Gets the computed result of this lazy supplier if ready. |
public T | Gets the computed result of this lazy supplier if ready, or prevents the computation of it in future calls. |
public boolean | Checks if the result value of this lazy supplier has already been computed. |
public static < | of( Creates a new lazy supplier that passes the given arguments to the calculator function. |
public static < | Creates a new lazy supplier that passes the given argument to the calculator function. |
public static < | of( Creates a new lazy supplier that uses the argument function to compute the lazy value. |
public static < | Creates a new lazy supplier that uses the argument supplier to compute the lazy value. |
public String | toString() Returns a string representation of the object. |
If the computer function returns null
, this function will still return null
even if the
result is already computed.
null
if not yet computed.
If the value of this lazy supplier has been already computed, or is being computed concurrently, this method
returns the computed value. If it hasn't been computed yet, and is not being concurrently computed, it will
return null
, and prevent the initialization of this supplier. (All future get() and other
calls will return null
.)
null
if not yet computed.true
if the result is ready.null
.null
.null
.The function will be applied with the returned lazy supplier as its function argument.
Using this function to create a lazy supplier can avoid the chicken-egg problem when the computing function wishes to reference the created lazy supplier in its computing function. Some computer functions may have an use-case for this, as the computer function may have side effects.
toString
method returns a string that
"textually represents" this object. The result should be a concise but informative representation that is easy
for a person to read. It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of
which the object is an instance, the at-sign character `@
', and the unsigned hexadecimal representation
of the hash code of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())