Interface Aggregator<E,​A>

  • Type Parameters:
    E - all events generated for this aggregate
    A - the aggregate type
    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 Aggregator<E,​A>
    An Aggregator is a function that builds up an aggregate from a stream of events (effectively a fold function). In Simple Sourcing, an Aggregate has one primary Aggregator that is guaranteed to be up-to-date with all events prior to executing a command against the aggregate.
    • Method Summary

      Modifier and Type Method Description
      A applyEvent​(A currentAggregate, E event)
      A function that takes the current aggregate value, the latest event and generates a new aggregate value.
    • Method Detail

      • applyEvent

        A applyEvent​(A currentAggregate,
                     E event)
        A function that takes the current aggregate value, the latest event and generates a new aggregate value. If no Aggregate exists, the InitialValue is used to create the starting value.
        Parameters:
        currentAggregate - the current aggregate value for this aggregate
        event - the latest event to apply to this aggregate
        Returns:
        the updated aggregate value for this aggregate after the given event has been applied