public class AnnotationCommandTargetResolver extends Object implements CommandTargetResolver
TargetAggregateIdentifier
. If on a method, the result of the invocation of that method will use as Aggregate
Identifier. If on a field, the value held in that field is used.
Similarly, the expected aggregate version may be provided by annotating a method (without parameters) or field with
TargetAggregateVersion
. The return value of the method or value held in the field is used as the expected
version. Note that the method must return a Long value, or a value that may be parsed as a Long.Modifier and Type | Class and Description |
---|---|
static class |
AnnotationCommandTargetResolver.Builder
Builder class to instantiate a
AnnotationCommandTargetResolver . |
Modifier | Constructor and Description |
---|---|
|
AnnotationCommandTargetResolver()
Deprecated.
Please use the
builder() . |
protected |
AnnotationCommandTargetResolver(AnnotationCommandTargetResolver.Builder builder)
Instantiate a
AnnotationCommandTargetResolver based on the fields contained in the AnnotationCommandTargetResolver.Builder . |
Modifier and Type | Method and Description |
---|---|
static AnnotationCommandTargetResolver.Builder |
builder()
Instantiate a Builder to be able to create a
AnnotationCommandTargetResolver . |
VersionedAggregateIdentifier |
resolveTarget(CommandMessage<?> command)
Returns the Aggregate Identifier and optionally the expected version of the aggregate on which the given
command should be executed. |
String |
toString() |
@Deprecated public AnnotationCommandTargetResolver()
builder()
.protected AnnotationCommandTargetResolver(AnnotationCommandTargetResolver.Builder builder)
AnnotationCommandTargetResolver
based on the fields contained in the AnnotationCommandTargetResolver.Builder
.builder
- the AnnotationCommandTargetResolver.Builder
used to instantiate a AnnotationCommandTargetResolver
instancepublic static AnnotationCommandTargetResolver.Builder builder()
AnnotationCommandTargetResolver
.
The TargetAggregateIdentifierAnnotation is defaulted to TargetAggregateIdentifier
,
TargetAggregateVersionAnnotation to TargetAggregateVersion
.
AnnotationCommandTargetResolver
public VersionedAggregateIdentifier resolveTarget(@Nonnull CommandMessage<?> command)
command
should be executed.
The version may be null
if no specific version is required. Furthermore, the returned
VersionedAggregateIdentifier
may be null entirely when the given command
is targeted towards a
CreationPolicy
annotated command handler that (optionally) constructs a new aggregate instance.
resolveTarget
in interface CommandTargetResolver
command
- The command from which to extract the identifier and version.VersionedAggregateIdentifier
instance reflecting the aggregate to execute the command on, or
null
when the command
is targeted towards a CreationPolicy
annotated command handler that
constructs a new aggregate instance.AggregateCreationPolicy.ALWAYS
,
AggregateCreationPolicy.CREATE_IF_MISSING
Copyright © 2010–2024. All rights reserved.