S
- The type of the object going through state transformations@API(status=EXPERIMENTAL,
since="1.7.0")
public interface ActionChain<S>
S
.
Since the next action is usually created on demand, the current runState
of a chain can be queried.
By default any action chain instance is not thread safe, i.e. you should not try to invoke run() concurrently.
Modifier and Type | Interface and Description |
---|---|
static class |
ActionChain.ActionChainFacade |
static class |
ActionChain.RunningState |
Modifier and Type | Method and Description |
---|---|
java.util.Optional<S> |
finalState()
The final state value after running an action chain.
|
ActionChain<S> |
peek(java.util.function.Consumer<S> peeker)
Observe the state transformations of a running chain by adding a peeker to an action chain.
|
S |
run()
Run the list through all transformations provided by the actions to create it.
|
ActionChain.RunningState |
running()
An action chain can be in different running states: NOT_RUN, RUNNING, FAILED, SUCEEDED
|
static <T> ActionChainArbitrary<T> |
startWith(java.util.function.Supplier<? extends T> initialSupplier)
Create arbitrary for a chain with a certain initial state.
|
java.util.List<java.lang.String> |
transformations()
Return list of all applied transformations.
|
java.util.List<Transformer<S>> |
transformers()
Return list of all used transformer instances.
|
default ActionChain<S> |
withInvariant(java.util.function.Consumer<S> invariant)
Add an unlabelled invariant to a sequence.
|
ActionChain<S> |
withInvariant(@Nullable java.lang.String label,
java.util.function.Consumer<S> invariant)
Add a labelled invariant to a sequence.
|
static <T> ActionChainArbitrary<T> startWith(java.util.function.Supplier<? extends T> initialSupplier)
T
- The type of state to be transformed through the chain.initialSupplier
- function to create the initial state objectjava.util.List<java.lang.String> transformations()
For a chain that has not been run this list is always empty.
@API(status=EXPERIMENTAL, since="1.7.1") java.util.List<Transformer<S>> transformers()
Checking transformer instances - e.g. if they are of a certain implementation type - only makes sense if the transformer's description string is NOT set explicitly, e.g. in an Action's description() method.
For a chain that has not been run this list is always empty.
S run()
default ActionChain<S> withInvariant(java.util.function.Consumer<S> invariant)
invariant
- will be checked after each successful actionwithInvariant(String, Consumer)
ActionChain<S> withInvariant(@Nullable java.lang.String label, java.util.function.Consumer<S> invariant)
label
- will show up in error messages when the invariant failsinvariant
- will be checked after each successful actionwithInvariant(Consumer)
java.util.Optional<S> finalState()
ActionChain.RunningState running()
ActionChain<S> peek(java.util.function.Consumer<S> peeker)
peeker
will be called after each successful transformation
but before checking invariants.
There can be more than one peeker.
peeker
- A consumer of a state object