Aggregate Part
public abstract class AggregatePart<I, S extends EntityState, B extends ValidatingBuilder<S>, R extends AggregateRoot<I>> extends Aggregate<I, S, B>
A part of a larger aggregate.
Some business logic objects may be big enough. If not all parts of such a business object need to be preserved at the same time as business logic invariants, such an object can be split into several parts.
Each such part would:
- be a class derived from
AggregatePart
- have the same aggregate ID as other parts belonging to the same business object
- have own state defined as a Protobuf message
- managed by a separate repository class derived from AggregateRepository
To access parts of the aggregate, AggregateRoot should be used.
If your business logic cannot be split into parts, it can be modified separately. Consider extending Aggregate instead of several AggregatePart
s.
Parameters
<I>
the type for IDs of this class of aggregates
<S>
the type of the state held by the aggregate part
<B>
the type of the aggregate part state builder
<R>
the type of the aggregate root
See also
Functions
Inherited functions
Link copied to clipboard
public void afterInvoke(HandlerMethod<? extends Object, ? extends Object, ? extends Object, ? extends Object> method)
A callback for a handler method invocation end.
Link copied to clipboard
public void beforeInvoke(HandlerMethod<? extends Object, ? extends Object, ? extends Object, ? extends Object> method)
A callback for a handler method invocation start.
Link copied to clipboard
Verifies the new entity state and returns ConstraintViolations, if any.
Link copied to clipboard
Ensures that the entity is not marked as
archived
.Link copied to clipboard
Ensures that the entity is not marked as
deleted
.Link copied to clipboard
Clears #recentHistory() recent history.
Link copied to clipboard
Obtains the default state of the entity.
Link copied to clipboard
Obtains a method for the passed command and invokes it.
Dispatches the passed command to appropriate handler.
Link copied to clipboard
Prohibits invoking state() method from within an applier method.
Link copied to clipboard
Creates
ValueMismatch
for the case of discovering a non-default value when the default value was expected by a command.Link copied to clipboard
Creates
ValueMismatch
for the case of discovering a non-empty value, when an empty string was expected by a command.Link copied to clipboard
Creates a
ValueMismatch
for a command that wanted to clear a value, but discovered that the field already has the default value.Creates a
ValueMismatch
for a command that wanted to change a field value, but discovered that the field has the default value.Link copied to clipboard
Creates a
ValueMismatch
for a command that wanted to clear a string value but discovered that the field is already empty.Link copied to clipboard
public static EventPlayer forTransactionOf(TransactionalEntity<? extends Object, ? extends Object, ? extends Object> entity)
Creates a transactional
EventPlayer
for the given entity.Link copied to clipboard
Obtains the current state of the entity lifecycle flags.
Link copied to clipboard
Creates an iterator of the aggregate event history with reverse traversal.
Link copied to clipboard
Verifies if the aggregate history contains an event which satisfies the passed predicate.
Link copied to clipboard
Obtains ID of the entity in the string form.
Link copied to clipboard
Tests whether the entity is marked as archived.
Link copied to clipboard
Obtains current lifecycle flags.
Link copied to clipboard
Tells whether lifecycle flags of the entity changed since its initialization.
Link copied to clipboard
Instructs to modify the state of an aggregate only within an event applier method.
Link copied to clipboard
Obtains the model class.
Link copied to clipboard
Obtains classes of the events produced by this object.
Link copied to clipboard
The object identity packed into Any.
Link copied to clipboard
Obtains recent history of events of this entity.
Link copied to clipboard
Adds events to the recent history.
Link copied to clipboard
Sets archived} status flag to the passed value.
Link copied to clipboard
Sets deleted} status flag to the passed value.
Link copied to clipboard
Sets an initial state for the entity.
Link copied to clipboard
Obtains model class for this entity.
Link copied to clipboard
Obtains the transaction used for modifying the entity.
Link copied to clipboard
Creates
ValueMismatch
for the case of discovering a value different than by a command.Creates
ValueMismatch
for the case of discovering a value different than expected by a command.Link copied to clipboard
Obtains the version number of the entity.
Link copied to clipboard
Obtains timestamp of the entity version.