Interface StateEvolver<EVENT,STATE>
-
- Type Parameters:
EVENT- The type of Events that can be applied in theapplyEvent(Object, Object)STATE- The type of aggregate/projection/viewSTATEthatapplyEvent(Object, Object)supports
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface StateEvolver<EVENT,STATE>
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description STATEapplyEvent(EVENT event, STATE state)Apply theEVENTto the aggregate/projection/viewSTATEinstance
Note: This method is calledevolvein the decider patternstatic <STATE,EVENT>
STATEapplyEvents(StateEvolver<EVENT,STATE> stateEvolver, STATE initialState, Stream<EVENT> eventStream)Perform a left-fold over theeventStreamusing theinitialStateas the initial state
-
-
-
Method Detail
-
applyEvent
STATE applyEvent(EVENT event, STATE state)
Apply theEVENTto the aggregate/projection/viewSTATEinstance
Note: This method is calledevolvein the decider pattern- Parameters:
event- theEVENTto be applied / projected onto the current aggregate/projection/viewSTATEstate- the currentSTATEof the aggregate/projection/view- Returns:
- the new aggregate/projection/view
STATE(after theEVENThas been applied / projected onto the current aggregate/projection/viewSTATE)
-
applyEvents
static <STATE,EVENT> STATE applyEvents(StateEvolver<EVENT,STATE> stateEvolver, STATE initialState, Stream<EVENT> eventStream)
Perform a left-fold over theeventStreamusing theinitialStateas the initial state- Type Parameters:
EVENT- The type of Events that can be applied in theapplyEvent(Object, Object)STATE- The type of aggregate/projection/viewSTATEthatapplyEvent(Object, Object)supports- Parameters:
stateEvolver- the state evolver (that applies events to the state)initialState- the initial state provided to the state evolvereventStream- the stream of Events supplied one by one (in-order) to the state evolver- Returns:
- the initial state with all events applied to it
-
-