Module org.fuin.ddd4j
Package org.fuin.ddd4j.ddd
Interface AggregateRoot<ID extends AggregateRootId>
- Type Parameters:
ID- Type of the aggregate root identifier.
- All Superinterfaces:
Entity<ID>
- All Known Implementing Classes:
AbstractAggregateRoot
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 Summary
Modifier and TypeMethodDescriptiongetId()Returns the unique aggregate root identifier.Returns the next version useful when creating an event for being applied:
apply(new MyEvent( ...intReturns the next version of the aggregate.@NotNull List<DomainEvent<?>>Returns a list of uncommitted changes.intReturns the current version of the aggregate.booleanReturns the information if the aggregate has uncommited changes.voidloadFromHistory(@NotNull List<DomainEvent<?>> history) Loads the aggregate with historic events.voidloadFromHistory(@NotNull DomainEvent<?>... history) Loads the aggregate with historic events.voidClears the internal change list and sets the new version number.
-
Method Details
-
getId
ID getId()Returns the unique aggregate root identifier.- Specified by:
getIdin interfaceEntity<ID extends AggregateRootId>- Returns:
- Identifier.
-
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
Loads the aggregate with historic events.- Parameters:
history- List of historic events.
-
loadFromHistory
Loads the aggregate with historic events.- Parameters:
history- List of historic events.
-