Interface AggregateRoot<ID extends AggregateRootId>

  • Type Parameters:
    ID - Type of the aggregate root identifier.
    All Superinterfaces:
    Entity<ID>
    All Known Implementing Classes:
    AbstractAggregateRoot

    public interface AggregateRoot<ID extends AggregateRootId>
    extends Entity<ID>
    Dedicated entity of a group of entities (The group is called "Aggregate") that guarantees the consistency of changes being made within the group by forbidding external objects from holding direct references to its members.
    • Method Detail

      • getId

        ID getId()
        Returns the unique aggregate root identifier.
        Specified by:
        getId in interface Entity<ID extends AggregateRootId>
        Returns:
        Identifier.
      • getUncommittedChanges

        @NotNull
        @NotNull List<DomainEvent<?>> getUncommittedChanges()
        Returns a list of uncommitted changes.
        Returns:
        List of events that were not persisted yet.
      • hasUncommitedChanges

        boolean hasUncommitedChanges()
        Returns the information if the aggregate has uncommited changes.
        Returns:
        TRUE if the aggregate will return a non-empty list for getUncommittedChanges(), else FALSE.
      • markChangesAsCommitted

        void markChangesAsCommitted()
        Clears the internal change list and sets the new version number.
      • getVersion

        int getVersion()
        Returns the current version of the aggregate.
        Returns:
        Current version that does NOT included uncommitted changes.
      • getNextVersion

        int getNextVersion()
        Returns the next version of the aggregate.
        Returns:
        Next version that includes all currently uncommitted changes.
      • getNextApplyVersion

        AggregateVersion getNextApplyVersion()
        Returns the next version useful when creating an event for being applied:
        apply(new MyEvent( ... , getNextApplyVersion())).
        Returns:
        Version for the event.
      • loadFromHistory

        void loadFromHistory​(@NotNull
                             @NotNull DomainEvent<?>... history)
        Loads the aggregate with historic events.
        Parameters:
        history - List of historic events.
      • loadFromHistory

        void loadFromHistory​(@NotNull
                             @NotNull List<DomainEvent<?>> history)
        Loads the aggregate with historic events.
        Parameters:
        history - List of historic events.