@ParametersAreNonnullByDefault public final class LazyInt extends Object
integer by using a IntSupplier during the first call to getAsInt().| Modifier and Type | Method and Description |
|---|---|
int |
getAsInt()
Gets the wrapped value.
|
void |
ifLoaded(IntConsumer 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 LazyInt |
of(int value)
Creates a new lazy integer with the embed value.
|
void |
unload()
Unloads the wrapped value.
|
void |
update(int newValue)
Updates the wrapped value.
|
void |
update(IntUnaryOperator updateOperator)
Updates the wrapped value with a
IntUnaryOperator. |
static LazyInt |
with(IntSupplier loadFunction)
Creates a new lazy integer with the
IntSupplier to load the embed value. |
@Nonnull public static LazyInt of(int value)
value - the embed value@Nonnull public static LazyInt with(IntSupplier loadFunction)
IntSupplier to load the embed value.loadFunction - the function used to load the valuepublic int getAsInt()
public void update(int newValue)
newValue - the new valuepublic void update(IntUnaryOperator updateOperator)
IntUnaryOperator.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(IntConsumer 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.