T
- The type of Aggregate created by this factorypublic abstract class AbstractAggregateFactory<T> extends Object implements AggregateFactory<T>
Modifier | Constructor and Description |
---|---|
protected |
AbstractAggregateFactory(AggregateModel<T> aggregateModel)
Initializes an
AggregateFactory for the given aggregateModel . |
protected |
AbstractAggregateFactory(Class<T> aggregateBaseType)
Initialize an
AggregateFactory for the given aggregateBaseType . |
protected |
AbstractAggregateFactory(Class<T> aggregateBaseType,
Set<Class<? extends T>> aggregateSubTypes)
Initialize an
AggregateFactory for the given polymorphic aggregateBaseType and it's aggregateSubTypes . |
Modifier and Type | Method and Description |
---|---|
protected AggregateModel<T> |
aggregateModel()
Gets the aggregate model.
|
T |
createAggregateRoot(String aggregateIdentifier,
DomainEventMessage<?> firstEvent)
Instantiate the aggregate root using the given aggregate identifier and first event.
|
protected abstract T |
doCreateAggregate(String aggregateIdentifier,
DomainEventMessage firstEvent)
Create an uninitialized Aggregate instance with the given
aggregateIdentifier . |
Class<T> |
getAggregateType()
Returns the type of aggregate this factory creates.
|
protected T |
postProcessInstance(T aggregate)
Perform any processing that must be done on an aggregate instance that was reconstructed from a Snapshot Event.
|
protected AbstractAggregateFactory(Class<T> aggregateBaseType)
AggregateFactory
for the given aggregateBaseType
.
If a first event is an instance of this aggregateBaseType
, it is recognised as a snapshot event.
Otherwise, the subclass is asked to instantiate a new aggregate root instance based on the first event.
aggregateBaseType
- the base type of the aggregate roots created by this instanceprotected AbstractAggregateFactory(Class<T> aggregateBaseType, Set<Class<? extends T>> aggregateSubTypes)
AggregateFactory
for the given polymorphic aggregateBaseType
and it's aggregateSubTypes
.
If a first event is an instance of this aggregateBaseType
, it is recognised as a snapshot event.
Otherwise, the subclass is asked to instantiate a new aggregate root instance based on the first event.
aggregateBaseType
- the base type of the aggregate roots created by this instanceaggregateSubTypes
- a Set
of sub types of the given aggregateBaseType
protected AbstractAggregateFactory(AggregateModel<T> aggregateModel)
AggregateFactory
for the given aggregateModel
.
If a first event is an instance of any aggregate root within this aggregateModel
, it is recognised as a
snapshot event. Otherwise, the subclass is asked to instantiate a new aggregate root instance based on the first
event.
aggregateModel
- the model of aggregate to be created by this factoryprotected AggregateModel<T> aggregateModel()
public final T createAggregateRoot(String aggregateIdentifier, DomainEventMessage<?> firstEvent)
AggregateFactory
createAggregateRoot
in interface AggregateFactory<T>
aggregateIdentifier
- the aggregate identifier of the aggregate to instantiatefirstEvent
- The first event in the event stream. This is either the event generated during
creation of the aggregate, or a snapshot eventprotected T postProcessInstance(T aggregate)
aggregate
- The aggregate to post-process.protected abstract T doCreateAggregate(String aggregateIdentifier, DomainEventMessage firstEvent)
aggregateIdentifier
. The given firstEvent
can be used to define the requirements of the aggregate to create.
The given firstEvent
is never a snapshot event.aggregateIdentifier
- The identifier of the aggregate to createfirstEvent
- The first event in the Event Stream of the Aggregatepublic Class<T> getAggregateType()
AggregateFactory
instanceOf
this type.getAggregateType
in interface AggregateFactory<T>
Copyright © 2010–2024. All rights reserved.