Class ImmutableAggregateRoot<T>
java.lang.Object
io.fluxcapacitor.javaclient.modeling.ImmutableEntity<T>
io.fluxcapacitor.javaclient.modeling.ImmutableAggregateRoot<T>
- Type Parameters:
T
- the type of the domain object represented by this aggregate root
- All Implemented Interfaces:
AggregateRoot<T>
,Entity<T>
Immutable representation of an
AggregateRoot
, extending ImmutableEntity
with additional metadata for
event sourcing.
The previous
field stores a reference to the prior state, enabling recursive traversal of historical states.
When aggregate caching with a caching depth
is enabled, older states may be replaced
by a LazyAggregateRoot
, which holds a reference but defers loading the full state.
This allows memory-efficient checkpointing of long-lived aggregates: once the maximum caching depth is reached, earlier states are no longer retained in memory and must be reloaded via event sourcing when accessed.
- 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
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapply
(DeserializingMessage message) Applies the given deserializing message to the entity.static <T> ImmutableAggregateRoot
<T> from
(Entity<T> a, EntityHelper entityHelper, Serializer serializer, EventStore eventStore) update
(UnaryOperator<T> function) Updates the current entity's value using the specified unary operator and returns a new entity containing the updated value.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 class io.fluxcapacitor.javaclient.modeling.ImmutableEntity
apply, assertLegal, commit, computeAliases, computeEntities, get, type, withType
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.fluxcapacitor.javaclient.modeling.AggregateRoot
lastEventId, lastEventIndex, parent, previous, sequenceNumber, timestamp
Methods inherited from interface io.fluxcapacitor.javaclient.modeling.Entity
aliases, allEntities, ancestors, ancestorValue, 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, withType
-
Constructor Details
-
ImmutableAggregateRoot
public ImmutableAggregateRoot()
-
-
Method Details
-
from
public static <T> ImmutableAggregateRoot<T> from(Entity<T> a, EntityHelper entityHelper, Serializer serializer, EventStore eventStore) -
apply
Description copied from interface:Entity
Applies the given deserializing message to the entity. -
update
Description copied from interface:Entity
Updates the current entity's value using the specified unary operator and returns a new entity containing the updated value. -
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 interfaceAggregateRoot<T>
- 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
-
withSequenceNumber
Description copied from interface:Entity
Returns an updated entity based on this with the specified sequence number.- Specified by:
withSequenceNumber
in interfaceAggregateRoot<T>
- 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
-