Interface EntityChildMetamodel<C,P>
- Type Parameters:
C- The type of the child entity.P- The type of the parent entity.
- All Superinterfaces:
EntityEvolver<P>
- All Known Implementing Classes:
AbstractEntityChildMetamodel,ListEntityChildMetamodel,SingleEntityChildMetamodel
Interface describing a child
EntityMetamodel that can be handled in the context of its parent. Handling
commands for this metamodel is done in the context of the parent. This metamodel resolves the child from the given
parent and can then invoke the right child instance to handle the command.- Since:
- 5.0.0
- Author:
- Mitchell Herrijgers
-
Method Summary
Modifier and TypeMethodDescriptionbooleancanHandle(CommandMessage message, P parentEntity, ProcessingContext context) Checks if this child can handle the givenCommandMessagefor the given parent entity, and a child entity is available to handle it.Returns theEntityMetamodelof the child entity this metamodel describes.Returns theClassof the child entity this metamodel describes.handle(CommandMessage message, P parentEntity, ProcessingContext context) Handles the givenCommandMessagefor the given child entity, using the provided parent entity.static <C,P> ListEntityChildMetamodel.Builder <C, P> list(Class<P> parentClass, EntityMetamodel<C> metamodel) Starts a builder for a list of child entities within the given parent entity type.static <C,P> SingleEntityChildMetamodel.Builder <C, P> single(Class<P> parentClass, EntityMetamodel<C> metamodel) Starts a builder for a single child entity within the given parent entity type.Returns the set of allQualifiedNamesthat this metamodel supports for command handlers.Methods inherited from interface org.axonframework.modelling.EntityEvolver
evolve
-
Method Details
-
supportedCommands
Returns the set of allQualifiedNamesthat this metamodel supports for command handlers.- Returns:
- A set of
QualifiedNameinstances representing the supported command names.
-
canHandle
boolean canHandle(@Nonnull CommandMessage message, @Nonnull P parentEntity, @Nonnull ProcessingContext context) Checks if this child can handle the givenCommandMessagefor the given parent entity, and a child entity is available to handle it.- Parameters:
message- TheCommandMessageto check.parentEntity- The parent entity instance to check against.context- TheProcessingContextfor the command.- Returns:
trueif this child can handle the command,falseotherwise.
-
handle
@Nonnull MessageStream.Single<CommandResultMessage> handle(@Nonnull CommandMessage message, @Nonnull P parentEntity, @Nonnull ProcessingContext context) Handles the givenCommandMessagefor the given child entity, using the provided parent entity.- Parameters:
message- TheCommandMessageto handle.parentEntity- The child entity instance to handle the command for.context- TheProcessingContextfor the command.- Returns:
- The result of the command handling, which may be a
CommandResultMessageor an error message.
-
entityType
Returns theClassof the child entity this metamodel describes.- Returns:
- The
Classof the child entity this metamodel describes.
-
entityMetamodel
Returns theEntityMetamodelof the child entity this metamodel describes.- Returns:
- The
EntityMetamodelof the child entity this metamodel describes.
-
single
@Nonnull static <C,P> SingleEntityChildMetamodel.Builder<C,P> single(@Nonnull Class<P> parentClass, @Nonnull EntityMetamodel<C> metamodel) Starts a builder for a single child entity within the given parent entity type.- Type Parameters:
C- The type of the child entity.P- The type of the parent entity.- Parameters:
parentClass- The class of the parent entity.metamodel- TheEntityMetamodelof the child entity.- Returns:
- A
SingleEntityChildMetamodel.Builderfor the child entity.
-
list
@Nonnull static <C,P> ListEntityChildMetamodel.Builder<C,P> list(@Nonnull Class<P> parentClass, @Nonnull EntityMetamodel<C> metamodel) Starts a builder for a list of child entities within the given parent entity type.- Type Parameters:
C- The type of the child entity.P- The type of the parent entity.- Parameters:
parentClass- The class of the parent entity.metamodel- TheEntityMetamodelof the child entity.- Returns:
- A
ListEntityChildMetamodel.Builderfor the child entity.
-