Class ImmutableModelRoot<T>
java.lang.Object
io.fluxzero.sdk.modeling.ImmutableEntity<T>
io.fluxzero.sdk.modeling.ImmutableRoot<T>
io.fluxzero.sdk.modeling.ImmutableModelRoot<T>
- Type Parameters:
T- model value type
- All Implemented Interfaces:
Entity<T>, ModelRoot<T>, PersistedRoot<T>
Immutable entity wrapper for one independently stored model revision.
Model sequence numbers are local to the model stream. ModelRoot.stateIndex() is the namespace-wide state boundary at
which this revision became current; it is deliberately distinct from the global event-log index exposed through
Entity.lastEventIndex().
-
Nested Class Summary
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> ImmutableModelRoot<T> Creates a lightweight new or staged model root without runtime collaborators.static <T> ImmutableModelRoot<T> initial(Object id, Class<T> type, String idProperty, T value, EntityHelper entityHelper, Serializer serializer) Creates a new uncommitted model root with the current timestamp.static <T> ImmutableModelRoot<T> revision(Object id, Class<T> type, String idProperty, T value, EntityHelper entityHelper, Serializer serializer, String lastEventId, Long lastEventIndex, Instant timestamp, long sequenceNumber, long stateIndex, Entity<T> previous) Creates a model root from one authoritative stored revision.static <T> ImmutableModelRoot<T> Creates a lightweight staged model root with its known sequence number.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 revision with the supplied 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, apply, assertApplyCompatibility, assertApplyCompatibility, assertLegal, clearLoadingRouteCache, commit, computeAliases, computeEntities, descendantTargetMetadata, entities, get, restoreLoadingRouteCache, snapshotLoadingRouteCache, type, update, withTypeMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Entity
aliases, allEntities, ancestors, ancestorValue, apply, 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, update, withTypeMethods inherited from interface ModelRoot
stateIndexMethods inherited from interface PersistedRoot
lastEventId, lastEventIndex, parent, previous, sequenceNumber, timestamp
-
Method Details
-
initial
public static <T> ImmutableModelRoot<T> initial(Object id, Class<T> type, String idProperty, T value, EntityHelper entityHelper, Serializer serializer) Creates a new uncommitted model root with the current timestamp. -
initial
public static <T> ImmutableModelRoot<T> initial(Object id, Class<T> type, String idProperty, T value) Creates a lightweight new or staged model root without runtime collaborators. -
staged
public static <T> ImmutableModelRoot<T> staged(Object id, Class<T> type, String idProperty, T value, long sequenceNumber) Creates a lightweight staged model root with its known sequence number. -
revision
public static <T> ImmutableModelRoot<T> revision(Object id, Class<T> type, String idProperty, T value, EntityHelper entityHelper, Serializer serializer, String lastEventId, Long lastEventIndex, Instant timestamp, long sequenceNumber, long stateIndex, Entity<T> previous) Creates a model root from one authoritative stored revision. -
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>- 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 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
-
withPrevious
Returns this revision with the supplied in-memory predecessor.- Specified by:
withPreviousin classImmutableRoot<T>
-