Class MapEntityChildMetamodel<K,C,P>
- Type Parameters:
K- the type of the key of theMapcontaining the child entitiesC- the type of the child entityP- the type of the parent entity
- All Implemented Interfaces:
EntityChildMetamodel<C,,P> EntityEvolver<P>
EntityChildMetamodel that handles commands and events for child entities stored in a Map.
It will use the provided ChildEntityFieldDefinition to resolve the child entities from the parent entity.
Once the entities are resolved, it will delegate the command- and event-handling to the child entity metamodel(s),
based on the commandTargetResolver and eventTargetMatcher respectively.
The identity of a child entity is the Map's own key. This means the key of a child entity is preserved across
events: a child that is evolved keeps its original key, and a child that is evolved to null is removed from
the map under that same key.
- Since:
- 5.3.0
- Author:
- Steven van Beelen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for creating aMapEntityChildMetamodelfor 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 <K,C, P> MapEntityChildMetamodel.Builder <K, C, P> forEntityModel(Class<P> parentClass, EntityMetamodel<C> entityMetamodel) Creates a newMapEntityChildMetamodel.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
-
forEntityModel
public static <K,C, MapEntityChildMetamodel.Builder<K,P> C, forEntityModelP> (Class<P> parentClass, EntityMetamodel<C> entityMetamodel) Creates a newMapEntityChildMetamodel.Builderfor the given parent class and child entity metamodel.The
ChildEntityFieldDefinitionis required to resolve the child entities from the parent entity and evolve the parent entity based on the child entities. TheCommandTargetResolverandEventTargetMatcherare both required, as they are used to match the child entities to the command and event respectively.- Type Parameters:
K- the type of the key of theMapcontaining the child entitiesC- the type of the child entityP- the type of the parent entity- Parameters:
parentClass- the class of the parent entityentityMetamodel- theEntityMetamodelof the child entity- Returns:
- a new
MapEntityChildMetamodel.Builderfor the given parent class and child entity metamodel
-
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
-