Class AbstractEntityChildMetamodel<C,P>
java.lang.Object
org.axonframework.modelling.entity.child.AbstractEntityChildMetamodel<C,P>
- Type Parameters:
C- The type of the child entity.P- The type of the parent entity.
- All Implemented Interfaces:
EntityChildMetamodel<C,,P> EntityEvolver<P>
- Direct Known Subclasses:
ListEntityChildMetamodel,SingleEntityChildMetamodel
public abstract class AbstractEntityChildMetamodel<C,P>
extends Object
implements EntityChildMetamodel<C,P>
Abstract
EntityChildMetamodel that implements common functionality for most implementations. It
defines how to handle commands and events for a child entity. The implementor is responsible for defining how to
resolve the child entities from the parent (getChildEntities(Object)) and how to apply the evolved child
entities to the parent (applyEvolvedChildEntities(Object, List)).- Since:
- 5.0.0
- Author:
- Mitchell Herrijgers
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final CommandTargetResolver<C> protected final EventTargetMatcher<C> protected final EntityMetamodel<C> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractEntityChildMetamodel(EntityMetamodel<C> metamodel, CommandTargetResolver<C> commandTargetResolver, EventTargetMatcher<C> eventTargetMatcher) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract PapplyEvolvedChildEntities(P entity, List<C> evolvedChildEntities) booleancanHandle(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 theClassof the child entity this metamodel describes.evolve(P entity, EventMessage event, ProcessingContext context) Evolve the givenentityby applying the giveneventto it.getChildEntities(P entity) handle(CommandMessage message, P parentEntity, ProcessingContext context) Handles the givenCommandMessagefor the given child entity, using the provided parent entity.Returns the set of allQualifiedNamesthat this metamodel supports for command handlers.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.axonframework.modelling.entity.child.EntityChildMetamodel
entityMetamodel
-
Field Details
-
metamodel
-
commandTargetResolver
-
eventTargetMatcher
-
-
Constructor Details
-
AbstractEntityChildMetamodel
protected AbstractEntityChildMetamodel(@Nonnull EntityMetamodel<C> metamodel, @Nonnull CommandTargetResolver<C> commandTargetResolver, @Nonnull EventTargetMatcher<C> eventTargetMatcher)
-
-
Method Details
-
supportedCommands
Description copied from interface:EntityChildMetamodelReturns the set of allQualifiedNamesthat this metamodel supports for command handlers.- Specified by:
supportedCommandsin interfaceEntityChildMetamodel<C,P> - Returns:
- A set of
QualifiedNameinstances representing the supported command names.
-
canHandle
public boolean canHandle(@Nonnull CommandMessage message, @Nonnull P parentEntity, @Nonnull ProcessingContext context) Description copied from interface:EntityChildMetamodelChecks if this child can handle the givenCommandMessagefor the given parent entity, and a child entity is available to handle it.- Specified by:
canHandlein interfaceEntityChildMetamodel<C,P> - 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 public MessageStream.Single<CommandResultMessage> handle(@Nonnull CommandMessage message, @Nonnull P parentEntity, @Nonnull ProcessingContext context) Description copied from interface:EntityChildMetamodelHandles the givenCommandMessagefor the given child entity, using the provided parent entity.- Specified by:
handlein interfaceEntityChildMetamodel<C,P> - 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.
-
getChildEntities
-
evolve
Description copied from interface:EntityEvolverEvolve the givenentityby applying the giveneventto it.- Specified by:
evolvein interfaceEntityEvolver<C>- Parameters:
entity- The current entity to evolve with the givenevent.event- The event that might adjust theentity.context- The context within which to evolve theentityby the givenevent.- Returns:
- The evolved
entitybased on the givenevent, or the sameentitywhen nothing happened.
-
applyEvolvedChildEntities
-
entityType
Description copied from interface:EntityChildMetamodelReturns theClassof the child entity this metamodel describes.- Specified by:
entityTypein interfaceEntityChildMetamodel<C,P> - Returns:
- The
Classof the child entity this metamodel describes.
-