Class AbstractChildEntityDefinition

java.lang.Object
org.axonframework.modelling.command.inspection.AbstractChildEntityDefinition
All Implemented Interfaces:
ChildEntityDefinition
Direct Known Subclasses:
AggregateMemberAnnotatedChildEntityCollectionDefinition, AggregateMemberAnnotatedChildEntityDefinition, AggregateMemberAnnotatedChildEntityMapDefinition

public abstract class AbstractChildEntityDefinition extends Object implements ChildEntityDefinition
Abstract implementation of the ChildEntityDefinition to provide reusable functionality for collections of ChildEntityDefinitions.
Since:
3.1
Author:
Steven van Beelen
  • Constructor Details

    • AbstractChildEntityDefinition

      public AbstractChildEntityDefinition()
  • Method Details

    • createChildDefinition

      public <T> Optional<ChildEntity<T>> createChildDefinition(Member member, EntityModel<T> declaringEntity)
      Description copied from interface: ChildEntityDefinition
      Inspect the given member, which is declared on the given declaringEntity for the presence of a Child Entity.
      Specified by:
      createChildDefinition in interface ChildEntityDefinition
      Type Parameters:
      T - the type of entity on which the field is declared
      Parameters:
      member - the member potentially containing a Child entity
      declaringEntity - the entity model declaring the field
      Returns:
      an optional that resolved to a ChildEntity if the field represents a child
    • isFieldTypeSupported

      @Deprecated protected boolean isFieldTypeSupported(Field field)
      Deprecated.
      Check whether the given Field is of a type supported by this definition.
      Parameters:
      field - a Field containing a Child Entity
      Returns:
      true if the type is as required by the implementation and false if it is not
    • isMemberTypeSupported

      protected abstract boolean isMemberTypeSupported(Member member)
      Check whether the given Member is of a type supported by this definition.
      Parameters:
      member - a Member containing 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 given declaringEntity as an EntityModel. The type of the Child Entity is defined through a key in the provided attributes or based on given Field.
      Type Parameters:
      T - the type T of the given declaringEntity EntityModel
      Parameters:
      declaringEntity - the EntityModel declaring the given field
      attributes - a Map containing the AggregateMember attributes
      member - the Member containing 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 incoming CommandMessage to the right Child Entity. Returns the Child Entity the msg needs to be routed to.
      Type Parameters:
      T - the type T of the given parent Entity
      Parameters:
      msg - the CommandMessage which is being resolved to a target entity
      parent - the parent Entity of type T of this Child Entity
      member - the Member containing the Child Entity.
      childEntityModel - the EntityModel for 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 given childEntityModel to be able to correctly route commands to Entities.
      Parameters:
      member - a Member denoting the Child Entity upon which the childEntityModel is based
      childEntityModel - a EntityModel to retrieve the routing key properties from
      Returns:
      a Map of key/value types String Property from 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 incoming EventMessage to the right Child Entities. Returns a Stream of all the Child Entities the Event Message should be routed to.
      Type Parameters:
      T - the type T of the given parent Entity
      Parameters:
      message - the EventMessage to route
      parentEntity - the parent Entity of type T of this Child Entity
      member - the Member containing the Child Entity
      eventForwardingMode - the ForwardingMode used to filter the message to route based on the ForwardingMode implementation
      Returns:
      a filtered Stream of Child Entity targets for the incoming EventMessage