Class SingleEntityChildMetamodel<C,P>
java.lang.Object
org.axonframework.modelling.entity.child.AbstractEntityChildMetamodel<C,P>
org.axonframework.modelling.entity.child.SingleEntityChildMetamodel<C,P>
- Type Parameters:
C- the type of the child entityP- the type of the parent entity
- All Implemented Interfaces:
EntityChildMetamodel<C,,P> EntityEvolver<P>
An
EntityChildMetamodel that handles commands and events for a single child entity.
It will use the provided ChildEntityFieldDefinition to resolve the child entity from the parent entity. Once
the entity is resolved, it will delegate the command- and event-handling to the child entity metamodel.
The commands and events will, by default, be forwarded unconditionally to the child entity. If you have multiple
member fields, and want to match commands and events to a specific child entity, you can configure the
CommandTargetResolver and EventTargetMatcher to match the child entity based on the command or
event.
- Since:
- 5.0.0
- Author:
- Mitchell Herrijgers
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for creating aSingleEntityChildMetamodelfor the given parent class and child entity metamodel. -
Field Summary
Fields inherited from class org.axonframework.modelling.entity.child.AbstractEntityChildMetamodel
commandTargetResolver, eventTargetMatcher, metamodel -
Method Summary
Modifier and TypeMethodDescriptionprotected PapplyEvolvedChildEntities(P entity, Map<Object, C> evolvedChildEntities) Applies the evolved child entities, keyed by the same implementation-specific identity returned byAbstractEntityChildMetamodel.getChildEntities(Object), to the givenentity.Returns theEntityMetamodelof the child entity this metamodel describes.static <C,P> SingleEntityChildMetamodel.Builder <C, P> forEntityModel(Class<P> parentClass, EntityMetamodel<C> metamodel) Creates a newSingleEntityChildMetamodel.Builderfor the given parent class and child entity metamodel.getChildEntities(P parent) Resolves the child entities of the givenparent, keyed by an implementation-specific identity.toString()Methods inherited from class org.axonframework.modelling.entity.child.AbstractEntityChildMetamodel
canHandle, entityType, evolve, handle, supportedCommands
-
Method Details
-
getChildEntities
Description copied from class:AbstractEntityChildMetamodelResolves the child entities of the givenparent, keyed by an implementation-specific identity.The returned immutable
Mapmust preserve iteration order (e.g.LinkedHashMap), as that order determines the order in which candidates are offered to theCommandTargetResolverandEventTargetMatcher.- Specified by:
getChildEntitiesin classAbstractEntityChildMetamodel<C,P> - Parameters:
parent- the parent entity to resolve the child entities from- Returns:
- the child entities of the given
parent, keyed by an implementation-specific identity
-
applyEvolvedChildEntities
Description copied from class:AbstractEntityChildMetamodelApplies the evolved child entities, keyed by the same implementation-specific identity returned byAbstractEntityChildMetamodel.getChildEntities(Object), to the givenentity. A key that was present inAbstractEntityChildMetamodel.getChildEntities(Object)but is absent fromevolvedChildEntitiesindicates that the corresponding child entity was evolved tonulland should be removed.- Specified by:
applyEvolvedChildEntitiesin classAbstractEntityChildMetamodel<C,P> - Parameters:
entity- the parent entity to apply the evolved child entities toevolvedChildEntities- the evolved child entities, keyed by the same identity asAbstractEntityChildMetamodel.getChildEntities(Object)- Returns:
- the evolved parent entity
-
entityMetamodel
Description copied from interface:EntityChildMetamodelReturns theEntityMetamodelof the child entity this metamodel describes.- Returns:
- the
EntityMetamodelof the child entity this metamodel describes
-
toString
-
forEntityModel
public static <C,P> SingleEntityChildMetamodel.Builder<C,P> forEntityModel(Class<P> parentClass, EntityMetamodel<C> metamodel) Creates a newSingleEntityChildMetamodel.Builderfor the given parent class and child entity metamodel. TheChildEntityFieldDefinitionis required to resolve the child entity from the parent entity and evolve the parent entity based on the child entities.- Type Parameters:
C- the type of the child entityP- the type of the parent entity- Parameters:
parentClass- the class of the parent entitymetamodel- theEntityMetamodelof the child entity- Returns:
- a new
SingleEntityChildMetamodel.Builderfor the given parent class and child entity metamodel
-