Class ImmutableAggregateRoot<T>
java.lang.Object
io.fluxzero.sdk.modeling.ImmutableEntity<T>
io.fluxzero.sdk.modeling.ImmutableRoot<T>
io.fluxzero.sdk.modeling.ImmutableAggregateRoot<T>
- Type Parameters:
T- the type of the domain object represented by this aggregate root
- All Implemented Interfaces:
AggregateRoot<T>, Entity<T>, PersistedRoot<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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classImmutableAggregateRoot.ImmutableAggregateRootBuilder<T, C extends ImmutableAggregateRoot<T>, B extends ImmutableAggregateRoot.ImmutableAggregateRootBuilder<T,C, B>> Keeps the pre-unification builder method descriptors for compiled Aggregate consumers.Nested classes/interfaces inherited from class ImmutableRoot
ImmutableRoot.ImmutableRootBuilder<T,C, B>, ImmutableRoot.ReplayContinuation<S, E>, ImmutableRoot.ReplayFailure<S, E>, ImmutableRoot.Transition<S, E> Nested classes/interfaces inherited from class ImmutableEntity
ImmutableEntity.ImmutableEntityBuilder<T,C, B> -
Field Summary
Fields inherited from interface Entity
AGGREGATE_ID_METADATA_KEY, AGGREGATE_SN_METADATA_KEY, AGGREGATE_TYPE_METADATA_KEY, ALREADY_EXISTS_EXCEPTION, applying, loading, NOT_FOUND_EXCEPTION -
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.withPrevious(Entity<T> previous) Returns this root revision with a different in-memory predecessor.withSequenceNumber(long sequenceNumber) Returns an updated entity based on this with the specified sequence number.Methods inherited from class ImmutableRoot
replay, replayUntil, retainPreviousMethods inherited from class ImmutableEntity
aliases, apply, assertApplyCompatibility, assertApplyCompatibility, assertLegal, clearLoadingRouteCache, commit, computeAliases, computeEntities, descendantTargetMetadata, entities, get, restoreLoadingRouteCache, snapshotLoadingRouteCache, type, withTypeMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface AggregateRoot
lastEventId, lastEventIndex, parent, previous, sequenceNumber, timestampMethods inherited from interface Entity
aliases, allEntities, ancestors, ancestorValue, apply, apply, apply, apply, apply, assertAndApply, assertAndApply, assertAndApply, assertAndApply, assertLegal, associations, commit, depth, dissociations, entities, filterEntity, filterPresent, findEntity, get, getEntity, getEntity, highestEventIndex, id, idProperty, ifPresent, isEmpty, isPresent, isRoot, map, mapEntity, mapIfPresent, orElse, orElseGet, orElseThrow, orElseThrow, playBackToCondition, playBackToEvent, possibleTargets, relationships, root, rootAnnotation, rootConfiguration, 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:EntityApplies the given deserializing message to the entity. -
withPrevious
Description copied from class:ImmutableRootReturns this root revision with a different in-memory predecessor.- Specified by:
withPreviousin classImmutableRoot<T>
-
update
Description copied from interface:EntityUpdates the current entity's value using the specified unary operator and returns a new entity containing the updated value. -
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 interfaceAggregateRoot<T>- Specified by:
withEventIndexin interfaceEntity<T>- Specified by:
withEventIndexin interfacePersistedRoot<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:EntityReturns an updated entity based on this with the specified sequence number.- Specified by:
withSequenceNumberin interfaceAggregateRoot<T>- Specified by:
withSequenceNumberin interfaceEntity<T>- Specified by:
withSequenceNumberin interfacePersistedRoot<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
-