Class Lazy<T>
java.lang.Object
org.eclipse.milo.opcua.stack.core.util.Lazy<T>
- Type Parameters:
T- the type of value computed and held.
Thread-safe holder for a lazily-computed value.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceLazy.ThrowingSupplier<E extends Exception,T> LikeSupplierbut it can throw an Exception. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet the lazily computed value, computing it if necessary usingsupplier.getOrThrow(Lazy.ThrowingSupplier<E, T> supplier) Get the lazily computed value, computing it if necessary usingsupplier.voidreset()Reset the value tonull.voidSet the value.
-
Constructor Details
-
Lazy
public Lazy()
-
-
Method Details
-
get
Get the lazily computed value, computing it if necessary usingsupplier.nullvalues returned by the supplier are not held, i.e. the next call will compute the value again.- Parameters:
supplier- aSupplierthat computes the value if necessary.- Returns:
- the lazily computed value.
-
getOrThrow
Get the lazily computed value, computing it if necessary usingsupplier.nullvalues returned by the supplier are not held, i.e. the next call will compute the value again.- Parameters:
supplier- aLazy.ThrowingSupplierthat computes the value if necessary.- Returns:
- the lazily computed value.
- Throws:
E- if the supplier throws an exception.
-
set
Set the value.- Parameters:
value- the value to set.
-
reset
public void reset()Reset the value tonull.
-