Interface Decider<COMMAND,EVENT,ERROR,STATE>
-
- Type Parameters:
COMMAND- The type of Commands that theHandler.handle(Object, Object)can processEVENT- The type of Events that can be returned byHandler.handle(Object, Object)and applied in theStateEvolver.applyEvent(Object, Object)ERROR- The type of Error that can be returned by theHandler.handle(Object, Object)methodSTATE- The type of Aggregate State that thisDeciderworks with inHandler.handle(Object, Object),InitialStateProvider.initialState(),StateEvolver.applyEvent(Object, Object)andisFinal(Object)
- All Superinterfaces:
Handler<COMMAND,EVENT,ERROR,STATE>,InitialStateProvider<STATE>,IsStateFinalResolver<STATE>,StateEvolver<EVENT,STATE>
public interface Decider<COMMAND,EVENT,ERROR,STATE> extends Handler<COMMAND,EVENT,ERROR,STATE>, StateEvolver<EVENT,STATE>, InitialStateProvider<STATE>, IsStateFinalResolver<STATE>
Variant of the event sourced Decider pattern, which supports building an AggregateSTATEbased on previousEVENT's that relate to the aggregate instance, and which can handleCOMMAND's, whose side effect is either anERRORor a List ofEVENT's (can be an empty list)
-
-
Method Summary
All Methods Static Methods Instance Methods Default Methods Modifier and Type Method Description static <COMMAND,EVENT,ERROR,STATE>
Decider<COMMAND,EVENT,ERROR,STATE>decider(Handler<COMMAND,EVENT,ERROR,STATE> handler, InitialStateProvider<STATE> initialStateProvider, StateEvolver<EVENT,STATE> stateEvolver, IsStateFinalResolver<STATE> stateIsStateFinalResolver)default booleanisFinal(STATE state)Return true from this method IF the aggregate's state is final and no more changes can occur, i.e.-
Methods inherited from interface dk.cloudcreate.essentials.components.eventsourced.aggregates.decider.Handler
handle
-
Methods inherited from interface dk.cloudcreate.essentials.components.eventsourced.aggregates.decider.InitialStateProvider
initialState
-
Methods inherited from interface dk.cloudcreate.essentials.components.eventsourced.aggregates.decider.StateEvolver
applyEvent
-
-
-
-
Method Detail
-
decider
static <COMMAND,EVENT,ERROR,STATE> Decider<COMMAND,EVENT,ERROR,STATE> decider(Handler<COMMAND,EVENT,ERROR,STATE> handler, InitialStateProvider<STATE> initialStateProvider, StateEvolver<EVENT,STATE> stateEvolver, IsStateFinalResolver<STATE> stateIsStateFinalResolver)
Factory method for creating aDeciderinstance from instances of the variousDeciderrelated interfaces- Type Parameters:
COMMAND- The type of Commands that theHandler.handle(Object, Object)can processEVENT- The type of Events that can be returned byHandler.handle(Object, Object)and applied in theStateEvolver.applyEvent(Object, Object)ERROR- The type of Error that can be returned by theHandler.handle(Object, Object)methodSTATE- The type of Aggregate State that thisDeciderworks with inHandler.handle(Object, Object),InitialStateProvider.initialState(),StateEvolver.applyEvent(Object, Object)andisFinal(Object)- Parameters:
handler- ADeciderrelated interface that is responsible for handlingCOMMAND(s)initialStateProvider- ADeciderrelated interface, which provides the InitialSTATEfor a given aggregate.stateEvolver- ADeciderrelated interface, which can applyEVENT<(s) to an aggregate/i>'sSTATEinstancestateIsStateFinalResolver- ADeciderrelated interface that resolves if the aggregate's state is final and no more changes can occur, i.e. no more events can be persisted- Returns:
- a
Deciderinstance that delegates to theDeciderrelated instances provided as parameters
-
isFinal
default boolean isFinal(STATE state)
Return true from this method IF the aggregate's state is final and no more changes can occur, i.e. no more events can be persisted (i.e.Handler.handle(Object, Object)will return anERROR)
Note: This method is calledisTerminalin the decider pattern
SeeIsStateFinalResolver.isFinal(Object)for more details.
The default implementation in theDecideralways returnfalse- Specified by:
isFinalin interfaceIsStateFinalResolver<COMMAND>- Parameters:
state- the currentSTATEof the aggregate- Returns:
- true IF the aggregate's state is final, otherwise false
-
-