Class NoOpEntity<T>
java.lang.Object
io.fluxcapacitor.javaclient.modeling.NoOpEntity<T>
- Type Parameters:
T
- the type of the entity's value
- All Implemented Interfaces:
Entity<T>
A read-only, inert
Entity
wrapper used exclusively during the loading phase of aggregate state.
NoOpEntity
is returned when an aggregate is accessed while Entity.isLoading()
is true
,
such as during event sourcing or the initialization of other aggregates. This occurs for instance when
an aggregate is loaded from within another aggregate’s @Apply
handler or any other mechanism
that recursively triggers loading.
This wrapper prevents any state mutation or validation during this phase by disabling:
apply()
– event reapplication is skippedupdate()
– no structural or state changes are madeassertLegal()
– validations are suppressedcommit()
– no changes are queued or published
get()
,id()
,type()
,entities()
,aliases()
, etc.- Delegation to parent or previous versions (wrapped in
NoOpEntity
)
This mechanism ensures that during loading, especially recursive or nested aggregate access,
no unintended updates are performed or committed. Outside of loading (i.e., when
Entity.isLoading()
is false
), such restrictions are lifted, and aggregates
may freely apply updates to other aggregates.
- 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 TypeMethodDescriptionCollection
<?> aliases()
Retrieves a collection of aliases associated with this entity.Applies the given message to the entity.<E extends Exception>
NoOpEntity<T> assertLegal
(Object update) Verifies that the provided update is legal given the current state of the aggregate.commit()
Commits the current state of the entity, persisting any changes made to it.Collection
<? extends Entity<?>> entities()
Retrieves child entities of this entity.get()
Retrieves the current instance of the entity.id()
Retrieves the unique identifier of the entity.Retrieves the name of the property that serves as the unique identifier for the entity.Entity
<?> parent()
Retrieves the parent entity of the current entity.previous()
Retrieves the previous version of this entity.type()
Retrieves the type of the entity.update
(UnaryOperator<T> function) Updates the current entity's value using the specified unary operator and returns a new entity containing the updated value.Sets the type of the entity to the specified class and returns the updated entity.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.Entity
allEntities, ancestors, ancestorValue, apply, apply, apply, apply, apply, assertAndApply, assertAndApply, assertAndApply, assertAndApply, associations, depth, dissociations, getEntity, highestEventIndex, ifPresent, isEmpty, isPresent, isRoot, lastEventId, lastEventIndex, mapIfPresent, playBackToCondition, playBackToEvent, possibleTargets, relationships, root, rootAnnotation, sequenceNumber, timestamp, withEventIndex, withSequenceNumber
-
Method Details
-
apply
Description copied from interface:Entity
Applies the given message to the entity. -
commit
Description copied from interface:Entity
Commits the current state of the entity, persisting any changes made to it. This method ensures that the modifications are saved. Typically, it is unnecessary to invoke this manually as it is automatically invoked after the current handler or consumer batch has completed. -
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. -
assertLegal
Description copied from interface:Entity
Verifies that the provided update is legal given the current state of the aggregate. If so, the entity is returned; otherwise, it throws an appropriate exception.- Specified by:
assertLegal
in interfaceEntity<T>
- Type Parameters:
E
- the type of exception expected if the update is not legal- Parameters:
update
- the update to be validated for compliance with the required rules- Returns:
- the entity if the update is legal
- Throws:
E
- if the update fails to meet legal requirements
-
parent
Description copied from interface:Entity
Retrieves the parent entity of the current entity. -
aliases
Description copied from interface:Entity
Retrieves a collection of aliases associated with this entity. -
entities
Description copied from interface:Entity
Retrieves child entities of this entity. -
previous
Description copied from interface:Entity
Retrieves the previous version of this entity. -
id
Description copied from interface:Entity
Retrieves the unique identifier of the entity. -
type
Description copied from interface:Entity
Retrieves the type of the entity. -
withType
Description copied from interface:Entity
Sets the type of the entity to the specified class and returns the updated entity. -
get
Description copied from interface:Entity
Retrieves the current instance of the entity. -
idProperty
Description copied from interface:Entity
Retrieves the name of the property that serves as the unique identifier for the entity.- Specified by:
idProperty
in interfaceEntity<T>
- Returns:
- the name of the identification property as a string
-