Type Parameters:
EVENT - The type of Events that can be applied in the applyEvent(Object, Object)
STATE - The type of aggregate/projection/view STATE that applyEvent(Object, Object) supports
All Known Subinterfaces:
Decider<COMMAND,EVENT,ERROR,STATE>, View<EVENT,STATE>
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>
A Decider or View related interface, which can apply EVENT<(s) to a aggregate/projection/view STATE instance
  • Method Summary

    Modifier and Type
    Method
    Description
    applyEvent(EVENT event, STATE state)
    Apply the EVENT to the aggregate/projection/view STATE instance
    Note: This method is called evolve in the decider pattern
    static <STATE, EVENT>
    STATE
    applyEvents(StateEvolver<EVENT,STATE> stateEvolver, STATE initialState, Stream<EVENT> eventStream)
    Perform a left-fold over the eventStream using the initialState as the initial state
  • Method Details

    • applyEvent

      STATE applyEvent(EVENT event, STATE state)
      Apply the EVENT to the aggregate/projection/view STATE instance
      Note: This method is called evolve in the decider pattern
      Parameters:
      event - the EVENT to be applied / projected onto the current aggregate/projection/view STATE
      state - the current STATE of the aggregate/projection/view
      Returns:
      the new aggregate/projection/view STATE (after the EVENT has been applied / projected onto the current aggregate/projection/view STATE)
    • applyEvents

      static <STATE, EVENT> STATE applyEvents(StateEvolver<EVENT,STATE> stateEvolver, STATE initialState, Stream<EVENT> eventStream)
      Perform a left-fold over the eventStream using the initialState as the initial state
      Type Parameters:
      EVENT - The type of Events that can be applied in the applyEvent(Object, Object)
      STATE - The type of aggregate/projection/view STATE that applyEvent(Object, Object) supports
      Parameters:
      stateEvolver - the state evolver (that applies events to the state)
      initialState - the initial state provided to the state evolver
      eventStream - the stream of Events supplied one by one (in-order) to the state evolver
      Returns:
      the initial state with all events applied to it