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
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 Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description IDgetId()Returns the unique aggregate root identifier.AggregateVersiongetNextApplyVersion()Returns the next version useful when creating an event for being applied:
apply(new MyEvent( ...intgetNextVersion()Returns the next version of the aggregate.@NotNull List<DomainEvent<?>>getUncommittedChanges()Returns a list of uncommitted changes.intgetVersion()Returns the current version of the aggregate.booleanhasUncommitedChanges()Returns 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.voidmarkChangesAsCommitted()Clears the internal change list and sets the new version number.
-
-
-
Method Detail
-
getId
ID getId()
Returns the unique aggregate root identifier.- Specified by:
getIdin interfaceEntity<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.
-
-