@API(status=EXPERIMENTAL,
since="1.2.3")
public interface Store<T>
Modifier and Type | Interface and Description |
---|---|
static class |
Store.StoreFacade |
Modifier and Type | Method and Description |
---|---|
static <T> Store<T> |
create(java.lang.Object identifier,
Lifespan lifespan,
java.util.function.Supplier<T> initializer)
Create a new store for storing and retrieving values and objects in lifecycle
hooks and lifecycle-dependent methods.
|
T |
get() |
static <T> Store<T> |
get(java.lang.Object identifier)
Retrieve a store that must be created somewhere else.
|
static <T> Store<T> |
getOrCreate(java.lang.Object identifier,
Lifespan lifespan,
java.util.function.Supplier<T> initializer)
Find an existing store or create a new one if it doesn't exist
|
Lifespan |
lifespan() |
Store<T> |
onClose(java.util.function.Consumer<T> onCloseCallback) |
void |
reset() |
void |
update(java.util.function.Function<T,T> updater) |
T get()
Lifespan lifespan()
void reset()
@API(status=EXPERIMENTAL, since="1.2.4") Store<T> onClose(java.util.function.Consumer<T> onCloseCallback)
static <T> Store<T> create(java.lang.Object identifier, Lifespan lifespan, java.util.function.Supplier<T> initializer)
T
- The type of object to storeidentifier
- Any object to identify a store. Must be globally unique.lifespan
- initializer
- Supplies the value to be used for initializing the store depending on its lifespanstatic <T> Store<T> getOrCreate(java.lang.Object identifier, Lifespan lifespan, java.util.function.Supplier<T> initializer)
T
- The type of object to storeidentifier
- Any object to identify a store. Must be globally unique.lifespan
- initializer
- Supplies the value to be used for initializing the store depending on its lifespanstatic <T> Store<T> get(java.lang.Object identifier)
T
- The type of object to storeidentifier
- Any object to identify a store. Must be globally unique.CannotFindStoreException