Interface AggregateRoot<T>
- Type Parameters:
T- the type of the underlying domain object
- All Superinterfaces:
Entity<T>
- All Known Implementing Classes:
ImmutableAggregateRoot, LazyAggregateRoot, ModifiableAggregateRoot
Represents the root of an aggregate in a domain model.
An AggregateRoot is a specialized Entity that serves as the entry point for a consistency boundary
in domain-driven design.
Unlike nested entities, an AggregateRoot's parent() is always null, as it is the top-level
context for its child entities.
previous() can be used to access the prior version of the aggregate, enabling differential processing.
- See Also:
-
Field Summary
Fields inherited from interface Entity
AGGREGATE_ID_METADATA_KEY, AGGREGATE_SN_METADATA_KEY, AGGREGATE_TYPE_METADATA_KEY, applying, loading -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the identifier of the last event applied to the entity hierarchy.Retrieves the index of the last event applied to this entity hierarchy.default Entity<?> parent()Retrieves the parent entity of the current entity.previous()Retrieves the previous version of this entity.longRetrieves the sequence number of the current entity.Retrieves the timestamp of the entity.withEventIndex(Long index, String messageId) Updates the event index and message ID of the entity and returns the updated version of the entity.withSequenceNumber(long sequenceNumber) Returns an updated entity based on this with the specified sequence number.Methods inherited from interface Entity
aliases, allEntities, ancestors, ancestorValue, apply, apply, apply, apply, apply, apply, assertAndApply, assertAndApply, assertAndApply, assertAndApply, assertLegal, associations, commit, depth, dissociations, entities, get, getEntity, highestEventIndex, id, idProperty, ifPresent, isEmpty, isPresent, isRoot, mapIfPresent, playBackToCondition, playBackToEvent, possibleTargets, relationships, root, rootAnnotation, type, update, withType
-
Method Details
-
parent
-
lastEventId
String lastEventId()Description copied from interface:EntityRetrieves the identifier of the last event applied to the entity hierarchy.- Specified by:
lastEventIdin interfaceEntity<T>- Returns:
- the identifier of the last event as a string, or null if no events have been recorded in the entity's aggregate
-
lastEventIndex
Long lastEventIndex()Description copied from interface:EntityRetrieves the index of the last event applied to this entity hierarchy.- Specified by:
lastEventIndexin interfaceEntity<T>- Returns:
- the index of the last event as a
Long, or null if no events have been recorded for the entity's aggregate
-
withEventIndex
Description copied from interface:EntityUpdates the event index and message ID of the entity and returns the updated version of the entity.- Specified by:
withEventIndexin interfaceEntity<T>- Parameters:
index- the event index to set for the root entitymessageId- the message ID associated with the event- Returns:
- the updated entity corresponding to the current entity's ID and type, or null if no such entity can be found
-
sequenceNumber
long sequenceNumber()Description copied from interface:EntityRetrieves the sequence number of the current entity.- Specified by:
sequenceNumberin interfaceEntity<T>- Returns:
- the sequence number of the root entity
-
withSequenceNumber
Description copied from interface:EntityReturns an updated entity based on this with the specified sequence number.- Specified by:
withSequenceNumberin interfaceEntity<T>- Parameters:
sequenceNumber- the sequence number to assign to the entity- Returns:
- the updated entity with the specified sequence number, or null if the entity could not be found in the entity hierarchy
-
timestamp
-
previous
-