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 Aggregate
STATE based on previous EVENT's that relate to the
aggregate instance, and which can handle COMMAND's, whose side effect is either an ERROR or a List of EVENT's (can be an empty list)-
Method Summary
Modifier and TypeMethodDescriptionstatic <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 booleanReturn 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
handleMethods inherited from interface dk.cloudcreate.essentials.components.eventsourced.aggregates.decider.InitialStateProvider
initialStateMethods inherited from interface dk.cloudcreate.essentials.components.eventsourced.aggregates.decider.StateEvolver
applyEvent
-
Method Details
-
decider
static <COMMAND,EVENT, Decider<COMMAND,ERROR, STATE> EVENT, deciderERROR, STATE> (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
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
-