T - the type of the embed value@ParametersAreNonnullByDefault public final class Lazy<T> extends Object
| Modifier and Type | Method and Description |
|---|---|
T |
get()
Gets the wrapped value.
|
void |
ifLoaded(Consumer<T> consumer)
If a value is loaded, invoke the specified
consumer with the value, otherwise do nothing. |
boolean |
isLoaded()
Returns
true if the value has been loaded. |
static <T> Lazy<T> |
of(T value)
Creates a new lazy object with the embed value.
|
void |
unload()
Unloads the wrapped value.
|
void |
update(T newValue)
Updates the wrapped value.
|
void |
update(UnaryOperator<T> updateOperator)
Updates the wrapped value with a
UnaryOperator. |
static <T> Lazy<T> |
with(Supplier<T> loadFunction)
Creates a new lazy object with the
Supplier to load the embed value. |
@Nonnull public static <T> Lazy<T> of(T value)
T - the type of the embed valuevalue - the embed value@Nonnull public static <T> Lazy<T> with(Supplier<T> loadFunction)
Supplier to load the embed value.T - the type of the embed valueloadFunction - the function used to load the valuepublic T get()
public void update(@Nullable T newValue)
newValue - the new valuepublic void update(UnaryOperator<T> updateOperator)
UnaryOperator.updateOperator - the operator to update the wrapped valuepublic boolean isLoaded()
true if the value has been loaded.true if the value has been loadedpublic void ifLoaded(Consumer<T> consumer)
consumer with the value, otherwise do nothing.consumer - action to be executed if a value is presentpublic void unload()
Copyright © 2017–2019 Atlanmod. All rights reserved.