Class DelegatingEntity<T>
- Type Parameters:
T
- the type of the entity's value
- All Implemented Interfaces:
Entity<T>
- Direct Known Subclasses:
ModifiableAggregateRoot
,ModifiableEntity
Entity
that forwards all method calls to a delegated Entity
instance.
DelegatingEntity
is designed to serve as a foundation for wrapper implementations that enrich or modify
entity behavior without altering the core entity logic. It simplifies the creation of decorator-style entities
such as ModifiableEntity
, SideEffectFreeEntity
, and ModifiableAggregateRoot
, allowing
selective method overriding while relying on delegation for the rest.
Subclasses typically override behavior like Entity.update(UnaryOperator)
, Entity.apply(Message)
,
or Entity.assertLegal(Object)
to add custom lifecycle behavior (e.g., interception, queuing, validation)
while maintaining compatibility with the Entity
interface.
By default, all methods delegate directly to the wrapped Entity
instance, which is exposed via the
#getDelegate()
accessor.
- See Also:
-
Field Summary
FieldsFields 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 TypeMethodDescriptionCollection
<?> aliases()
Retrieves a collection of aliases associated with this entity.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.Retrieves the identifier of the last event applied to the entity hierarchy.Retrieves the index of the last event applied to this entity hierarchy.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.type()
Retrieves the type 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.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, apply, assertAndApply, assertAndApply, assertAndApply, assertAndApply, assertLegal, associations, commit, depth, dissociations, getEntity, highestEventIndex, ifPresent, isEmpty, isPresent, isRoot, mapIfPresent, playBackToCondition, playBackToEvent, possibleTargets, relationships, root, rootAnnotation, update
-
Field Details
-
delegate
-
-
Constructor Details
-
DelegatingEntity
-
-
Method Details
-
id
Description copied from interface:Entity
Retrieves the unique identifier of the entity. -
aliases
Description copied from interface:Entity
Retrieves a collection of aliases associated with this entity. -
type
Description copied from interface:Entity
Retrieves the type of the 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
-
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
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
-
timestamp
Description copied from interface:Entity
Retrieves the timestamp of the entity. -
sequenceNumber
public 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
-
previous
Description copied from interface:Entity
Retrieves the previous version of this entity. -
entities
Description copied from interface:Entity
Retrieves child entities of this entity. -
parent
Description copied from interface:Entity
Retrieves the parent entity of the current entity. -
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
-
withType
Description copied from interface:Entity
Sets the type of the entity to the specified class and returns the updated 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
-