Package net.jqwik.api.lifecycle
Interface Store<T>
-
@API(status=EXPERIMENTAL, since="1.2.3") public interface Store<T>Experimental feature. Not ready for public usage yet.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classStore.StoreFacade
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method 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.Tget()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 existLifespanlifespan()Store<T>onClose(java.util.function.Consumer<T> onCloseCallback)voidreset()voidupdate(java.util.function.Function<T,T> updater)
-
-
-
Method Detail
-
get
T get()
-
lifespan
Lifespan lifespan()
-
reset
void reset()
-
onClose
@API(status=EXPERIMENTAL, since="1.2.4") Store<T> onClose(java.util.function.Consumer<T> onCloseCallback)
-
create
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.- Type Parameters:
T- The type of object to store- Parameters:
identifier- Any object to identify a store. Must be globally unique.lifespan- A stored object's lifespaninitializer- Supplies the value to be used for initializing the store depending on its lifespan- Returns:
- New store instance
-
getOrCreate
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- Type Parameters:
T- The type of object to store- Parameters:
identifier- 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 lifespan- Returns:
- New or existing store instance
-
get
static <T> Store<T> get(java.lang.Object identifier)
Retrieve a store that must be created somewhere else.- Type Parameters:
T- The type of object to store- Parameters:
identifier- Any object to identify a store. Must be globally unique.- Returns:
- Existing store instance
- Throws:
CannotFindStoreException
-
-