public class AnnotationCommandTargetResolver extends Object implements CommandTargetResolver
TargetAggregateIdentifier
. If on a method, the result of the invocation of that method will used 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 final AnnotationCommandTargetResolver.Builder builder()
AnnotationCommandTargetResolver
.
The TargetAggregateIdentifierAnnotation is defaulted to TargetAggregateIdentifier
,
TargetAggregateVersionAnnotation to TargetAggregateVersion
.
AnnotationCommandTargetResolver
public VersionedAggregateIdentifier resolveTarget(CommandMessage<?> command)
command
should be executed. The version may be null
if no specific version is required.resolveTarget
in interface CommandTargetResolver
command
- The command from which to extract the identifier and versionVersionedAggregateIdentifier
instance reflecting the aggregate to execute the command onCopyright © 2010–2019. All rights reserved.