Interface StateUpdater<T,S>
-
- All Superinterfaces:
Operation
,Serializable
public interface StateUpdater<T,S> extends Operation
Interface for updating state.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description S
apply(S state, T value)
Returns a new state by applying the value on the current state.S
init()
The initial value of the state to start with.static <T,S>
StateUpdater<T,S>of(S initialValue, BiFunction<? super S,? super T,? extends S> stateUpdateFn)
A static factory to create aStateUpdater
based on an initial value of the state and a state update function.
-
-
-
Method Detail
-
of
static <T,S> StateUpdater<T,S> of(S initialValue, BiFunction<? super S,? super T,? extends S> stateUpdateFn)
A static factory to create aStateUpdater
based on an initial value of the state and a state update function.- Parameters:
initialValue
- the intial value of the statestateUpdateFn
- the state update function- Returns:
- the
StateUpdater
-
init
S init()
The initial value of the state to start with.- Returns:
- the initial value of the state
-
-