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 io.fluxcapacitor.javaclient.modeling.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.long
Retrieves 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 io.fluxcapacitor.javaclient.modeling.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
Description copied from interface:Entity
Retrieves the parent entity of the current entity. -
lastEventId
String lastEventId()Description copied from interface:Entity
Retrieves the identifier of the last event applied to the entity hierarchy.- Specified by:
lastEventId
in 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:Entity
Retrieves the index of the last event applied to this entity hierarchy.- Specified by:
lastEventIndex
in 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:Entity
Updates the event index and message ID of the entity and returns the updated version of the entity.- Specified by:
withEventIndex
in 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:Entity
Retrieves the sequence number of the current entity.- Specified by:
sequenceNumber
in interfaceEntity<T>
- Returns:
- the sequence number of the root entity
-
withSequenceNumber
Description copied from interface:Entity
Returns an updated entity based on this with the specified sequence number.- Specified by:
withSequenceNumber
in 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
Instant timestamp()Description copied from interface:Entity
Retrieves the timestamp of the entity. -
previous
Description copied from interface:Entity
Retrieves the previous version of this entity.
-