/** * Instantiate a {@link AggregateAnnotationCommandHandler} based on the fields contained in the {@link Builder}. * <p> * Will assert that the {@link Repository} and {@link CommandTargetResolver} are not {@code null}, and will throw * an {@link AxonConfigurationException} if either of them is {@code null}. Next to that, the provided Builder's * goal is to create an {@link AggregateModel} (describing the structure of a given aggregate). To instantiate this * AggregateModel, either an {@link AggregateModel} can be provided directly or an {@code aggregateType} of type * {@link Class} can be used. The latter will internally resolve to an AggregateModel. Thus, either the * AggregateModel <b>or</b> the {@code aggregateType} should be provided. An AxonConfigurationException is thrown * if this criteria is not met. * * @param builder the {@link Builder} used to instantiate a {@link AggregateAnnotationCommandHandler} instance */ protected AggregateAnnotationCommandHandler(Builder<T> builder) { builder.validate(); this.repository = builder.repository; this.commandTargetResolver = builder.commandTargetResolver; this.supportedCommandNames = new HashSet<>(); this.handlers = initializeHandlers(builder.buildAggregateModel()); }
/** * Instantiate a {@link AggregateAnnotationCommandHandler} based on the fields contained in the {@link Builder}. * <p> * Will assert that the {@link Repository} and {@link CommandTargetResolver} are not {@code null}, and will throw * an {@link AxonConfigurationException} if either of them is {@code null}. Next to that, the provided Builder's * goal is to create an {@link AggregateModel} (describing the structure of a given aggregate). To instantiate this * AggregateModel, either an {@link AggregateModel} can be provided directly or an {@code aggregateType} of type * {@link Class} can be used. The latter will internally resolve to an AggregateModel. Thus, either the * AggregateModel <b>or</b> the {@code aggregateType} should be provided. An AxonConfigurationException is thrown * if this criteria is not met. * * @param builder the {@link Builder} used to instantiate a {@link AggregateAnnotationCommandHandler} instance */ protected AggregateAnnotationCommandHandler(Builder<T> builder) { builder.validate(); this.repository = builder.repository; this.commandTargetResolver = builder.commandTargetResolver; this.supportedCommandNames = new HashSet<>(); this.handlers = initializeHandlers(builder.buildAggregateModel()); }