Class AggregateState<ID,​EVENT_TYPE extends Event<ID>>

    • Constructor Detail

      • AggregateState

        public AggregateState()
    • Method Detail

      • getEventOrderOfLastAppliedEvent

        public dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.types.EventOrder getEventOrderOfLastAppliedEvent()
      • getEventOrderOfLastRehydratedEvent

        public dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.types.EventOrder getEventOrderOfLastRehydratedEvent()
      • apply

        protected final void apply​(EVENT_TYPE event)
        Apply a new non persisted/uncommitted Event to this aggregate instance.
        If it is the very FIRST Event that is being applied then Event.aggregateId() MUST return the ID of the aggregate the event relates to
        Every consecutive Event applied will have its Event.aggregateId(Object) method called IF it doesn't already have a value. I.e. you can be lazy and skip setting the aggregate id on the Event if you don't want to.

        The AggregateRoot automatically keeps track of the Event.eventOrder() value and will set it for you and ensure that it's growing consecutively.

        Parameters:
        event - the event to apply
      • aggregateId

        public ID aggregateId()
      • hasBeenRehydrated

        public boolean hasBeenRehydrated()
        Has rehydrate(Stream) been used
      • applyEventToTheAggregate

        protected void applyEventToTheAggregate​(Event<ID> event)
        Apply the event to the aggregate instance to reflect the event as a state change to the aggregate
        The default implementation will automatically call any (private) methods annotated with EventHandler
        Parameters:
        event - the event to apply to the aggregate
        See Also:
        isRehydrating()
      • eventOrderOfLastAppliedEvent

        public final dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.types.EventOrder eventOrderOfLastAppliedEvent()
        Get the of the last {}@link Event that was applied to the AggregateRoot (either using rehydrate(Stream) or using apply(Event)
        Returns:
        the event order of the last applied Event or EventOrder.NO_EVENTS_PREVIOUSLY_PERSISTED in case no events has ever been applied to the aggregate
      • uncommittedChanges

        public List<EVENT_TYPE> uncommittedChanges()
        The the events that have been applied to this aggregate instance but not yet persisted to the underlying EventStore
      • markChangesAsCommitted

        public void markChangesAsCommitted()
        Resets the uncommittedChanges() - effectively marking them as having been persisted and committed to the underlying EventStore