Class AggregateAnnotationCommandHandler.Builder<T>
- Type Parameters:
T- the type of aggregate thisAggregateAnnotationCommandHandlerhandles commands for
- Enclosing class:
AggregateAnnotationCommandHandler<T>
AggregateAnnotationCommandHandler.
The CommandTargetResolver is defaulted to an AnnotationCommandTargetResolver The
Repository is a hard requirement and as such should be provided. Next to that, this Builder's goal
is to provide an AggregateModel (describing the structure of a given aggregate). To instantiate this
AggregateModel, either an AggregateModel can be provided directly or an aggregateType of type
Class can be used. The latter will internally resolve to an AggregateModel. Thus, either the
AggregateModel
or the aggregateType should be provided.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaggregateModel(AggregateModel<T> aggregateModel) Sets theAggregateModelof generic typeT, describing the structure of the aggregate theAnnotationCommandHandlerAdapterwill handle.aggregateType(Class<T> aggregateType) Sets theaggregateTypeas aClass, specifying the type of aggregate anAggregateModelshould be created for.build()Initializes aAggregateAnnotationCommandHandleras specified through this Builder.commandTargetResolver(CommandTargetResolver commandTargetResolver) Sets theCommandTargetResolverused to resolve the command handling target.creationPolicyAggregateFactory(CreationPolicyAggregateFactory<T> creationPolicyAggregateFactory) Sets theCreationPolicyAggregateFactory<T>for generic typeT.handlerDefinition(HandlerDefinition handlerDefinition) Sets theHandlerDefinitionused to create concrete handlers for the givenaggregateType.parameterResolverFactory(ParameterResolverFactory parameterResolverFactory) Sets theParameterResolverFactoryused to resolve parameters for annotated handlers contained in the Aggregate.repository(Repository<T> repository) Sets theRepositoryused to add and load Aggregate instances of generic typeTupon handling commands for it.protected voidvalidate()Validates whether the fields contained in this Builder are set accordingly.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
repository
Sets theRepositoryused to add and load Aggregate instances of generic typeTupon handling commands for it.- Parameters:
repository- aRepositoryused to add and load Aggregate instances of generic typeTupon handling commands for it- Returns:
- the current Builder instance, for fluent interfacing
-
commandTargetResolver
public AggregateAnnotationCommandHandler.Builder<T> commandTargetResolver(CommandTargetResolver commandTargetResolver) Sets theCommandTargetResolverused to resolve the command handling target. Defaults to anAnnotationCommandTargetResolver.- Parameters:
commandTargetResolver- aCommandTargetResolverused to resolve the command handling target- Returns:
- the current Builder instance, for fluent interfacing
-
aggregateType
Sets theaggregateTypeas aClass, specifying the type of aggregate anAggregateModelshould be created for. Either this field or theaggregateModel(AggregateModel)should be provided to correctly instantiate anAggregateAnnotationCommandHandler.- Parameters:
aggregateType- theaggregateTypespecifying the type of aggregate anAggregateModelshould be instantiated for- Returns:
- the current Builder instance, for fluent interfacing
-
parameterResolverFactory
public AggregateAnnotationCommandHandler.Builder<T> parameterResolverFactory(ParameterResolverFactory parameterResolverFactory) Sets theParameterResolverFactoryused to resolve parameters for annotated handlers contained in the Aggregate. Only used if theaggregateTypeapproach is selected to create anAggregateModel.- Parameters:
parameterResolverFactory- aParameterResolverFactoryused to resolve parameters for annotated handlers contained in the Aggregate- Returns:
- the current Builder instance, for fluent interfacing
-
handlerDefinition
public AggregateAnnotationCommandHandler.Builder<T> handlerDefinition(HandlerDefinition handlerDefinition) Sets theHandlerDefinitionused to create concrete handlers for the givenaggregateType. Only used if theaggregateTypeapproach is selected to create anAggregateModel.- Parameters:
handlerDefinition- aHandlerDefinitionused to create concrete handlers for the givenaggregateType- Returns:
- the current Builder instance, for fluent interfacing
-
aggregateModel
public AggregateAnnotationCommandHandler.Builder<T> aggregateModel(AggregateModel<T> aggregateModel) Sets theAggregateModelof generic typeT, describing the structure of the aggregate theAnnotationCommandHandlerAdapterwill handle. Either this field or theaggregateType(Class)should be provided to correctly instantiate anAggregateAnnotationCommandHandler.- Parameters:
aggregateModel- theAggregateModelof generic typeTof the aggregate thisRepositorywill store- Returns:
- the current Builder instance, for fluent interfacing
-
creationPolicyAggregateFactory
public AggregateAnnotationCommandHandler.Builder<T> creationPolicyAggregateFactory(CreationPolicyAggregateFactory<T> creationPolicyAggregateFactory) Sets theCreationPolicyAggregateFactory<T>for generic typeT.The aggregate factory must produce a new instance of the aggregate root based on the supplied identifier. When dealing with a polymorphic aggregate, the given
creationPolicyAggregateFactorywill be used for everytype.- Parameters:
creationPolicyAggregateFactory- TheCreationPolicyAggregateFactorythe constructs an aggregate instance based on an identifier.- Returns:
- The current Builder instance, for fluent interfacing.
-
build
Initializes aAggregateAnnotationCommandHandleras specified through this Builder.- Returns:
- a
AggregateAnnotationCommandHandleras specified through this Builder
-
validate
Validates whether the fields contained in this Builder are set accordingly.- Throws:
AxonConfigurationException- if one field is asserted to be incorrect according to the Builder's specifications
-