Class AbstractChildEntityDefinition
java.lang.Object
org.axonframework.modelling.command.inspection.AbstractChildEntityDefinition
- All Implemented Interfaces:
ChildEntityDefinition
- Direct Known Subclasses:
AggregateMemberAnnotatedChildEntityCollectionDefinition,AggregateMemberAnnotatedChildEntityDefinition,AggregateMemberAnnotatedChildEntityMapDefinition
Abstract implementation of the
ChildEntityDefinition to provide reusable functionality for collections of
ChildEntityDefinitions.- Since:
- 3.1
- Author:
- Steven van Beelen
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> Optional<ChildEntity<T>> createChildDefinition(Member member, EntityModel<T> declaringEntity) Inspect the givenmember, which is declared on the givendeclaringEntityfor the presence of a Child Entity.protected abstract <T> EntityModel<Object> extractChildEntityModel(EntityModel<T> declaringEntity, Map<String, Object> attributes, Member member) Extracts the Child Entity contained in the givendeclaringEntityas anEntityModel.extractCommandHandlerRoutingKeys(Member member, EntityModel<Object> childEntityModel) Retrieves the routing keys of every command handler on the givenchildEntityModelto be able to correctly route commands to Entities.protected booleanisFieldTypeSupported(Field field) Deprecated.protected abstract booleanisMemberTypeSupported(Member member) Check whether the givenMemberis of a type supported by this definition.protected abstract <T> ObjectresolveCommandTarget(CommandMessage<?> msg, T parent, Member member, EntityModel<Object> childEntityModel) Resolve the target of an incomingCommandMessageto the right Child Entity.resolveEventTargets(EventMessage message, T parentEntity, Member member, ForwardingMode eventForwardingMode) Resolve the targets of an incomingEventMessageto the right Child Entities.
-
Constructor Details
-
AbstractChildEntityDefinition
public AbstractChildEntityDefinition()
-
-
Method Details
-
createChildDefinition
public <T> Optional<ChildEntity<T>> createChildDefinition(Member member, EntityModel<T> declaringEntity) Description copied from interface:ChildEntityDefinitionInspect the givenmember, which is declared on the givendeclaringEntityfor the presence of a Child Entity.- Specified by:
createChildDefinitionin interfaceChildEntityDefinition- Type Parameters:
T- the type of entity on which the field is declared- Parameters:
member- the member potentially containing a Child entitydeclaringEntity- the entity model declaring the field- Returns:
- an optional that resolved to a ChildEntity if the field represents a child
-
isFieldTypeSupported
Deprecated.in favour ofisMemberTypeSupported(Member)Check whether the givenFieldis of a type supported by this definition.- Parameters:
field- aFieldcontaining a Child Entity- Returns:
- true if the type is as required by the implementation and false if it is not
-
isMemberTypeSupported
Check whether the givenMemberis of a type supported by this definition.- Parameters:
member- aMembercontaining or returning a Child Entity- Returns:
- true if the type is as required by the implementation and false if it is not
-
extractChildEntityModel
protected abstract <T> EntityModel<Object> extractChildEntityModel(EntityModel<T> declaringEntity, Map<String, Object> attributes, Member member) Extracts the Child Entity contained in the givendeclaringEntityas anEntityModel. The type of the Child Entity is defined through a key in the providedattributesor based on givenField.- Type Parameters:
T- the typeTof the givendeclaringEntityEntityModel- Parameters:
declaringEntity- theEntityModeldeclaring the givenfieldattributes- aMapcontaining theAggregateMemberattributesmember- theMembercontaining the Child Entity.- Returns:
- the Child Entity contained in the
declaringEntity
-
resolveCommandTarget
protected abstract <T> Object resolveCommandTarget(CommandMessage<?> msg, T parent, Member member, EntityModel<Object> childEntityModel) Resolve the target of an incomingCommandMessageto the right Child Entity. Returns the Child Entity themsgneeds to be routed to.- Type Parameters:
T- the typeTof the givenparentEntity- Parameters:
msg- theCommandMessagewhich is being resolved to a target entityparent- theparentEntity of typeTof this Child Entitymember- theMembercontaining the Child Entity.childEntityModel- theEntityModelfor the Child Entity- Returns:
- the Child Entity which is the target of the incoming
CommandMessage.
-
extractCommandHandlerRoutingKeys
protected Map<String,Property<Object>> extractCommandHandlerRoutingKeys(Member member, EntityModel<Object> childEntityModel) Retrieves the routing keys of every command handler on the givenchildEntityModelto be able to correctly route commands to Entities.- Parameters:
member- aMemberdenoting the Child Entity upon which thechildEntityModelis basedchildEntityModel- aEntityModelto retrieve the routing key properties from- Returns:
- a
Mapof key/value typesStringPropertyfrom Command Message name to routing key
-
resolveEventTargets
protected abstract <T> Stream<Object> resolveEventTargets(EventMessage message, T parentEntity, Member member, ForwardingMode eventForwardingMode) Resolve the targets of an incomingEventMessageto the right Child Entities. Returns aStreamof all the Child Entities the Event Message should be routed to.- Type Parameters:
T- the typeTof the givenparentEntity- Parameters:
message- theEventMessageto routeparentEntity- theparentEntity of typeTof this Child Entitymember- theMembercontaining the Child EntityeventForwardingMode- theForwardingModeused to filter themessageto route based on the ForwardingMode implementation- Returns:
- a filtered
Streamof Child Entity targets for the incomingEventMessage
-
isMemberTypeSupported(Member)