Interface EntityModel<T>

Type Parameters:
T - The type of entity described by this model
All Known Subinterfaces:
AggregateModel<T>

public interface EntityModel<T>
Interface of an entity model that describes the properties and capabilities of an entity of type T. The entity may be child entity or an aggregate root.
  • Method Details

    • getIdentifier

      Object getIdentifier(T target)
      Get the identifier of the given target entity.
      Parameters:
      target - The entity instance
      Returns:
      The identifier of the given target entity
    • routingKey

      String routingKey()
      Get the name of the routing key property on commands and events that provides the identifier that should be used to target entities of this kind.
      Returns:
      The name of the routing key that holds the identifier used to target this sort of entity
    • publish

      void publish(EventMessage<?> message, T target)
      Publish given event message on the given target entity.
      Parameters:
      message - The event message to publish
      target - The target entity for the event
    • commandHandlers

      @Deprecated default List<MessageHandlingMember<? super T>> commandHandlers()
      Deprecated.
      Gets a mapping of MessageHandlingMember to command name (obtained via CommandMessage.getCommandName()) for this entityClass().
      Returns:
      a map of message handler to command name
    • allCommandHandlers

      default Map<Class<?>,List<MessageHandlingMember<? super T>>> allCommandHandlers()
      Gets all command handlers per type in this aggregate hierarchy.
      Returns:
      a map of command handlers per type
    • commandHandlers

      default Stream<MessageHandlingMember<? super T>> commandHandlers(Class<? extends T> type)
      Gets command handlers for provided type in this aggregate hierarchy.
      Parameters:
      type - the aggregate type in this hierarchy
      Returns:
      a stream of command handlers for provided type
    • commandHandlerInterceptors

      @Deprecated default List<MessageHandlingMember<? super T>> commandHandlerInterceptors()
      Gets a list of command handler interceptors for this entityClass().
      Returns:
      list of command handler interceptors
    • allCommandHandlerInterceptors

      default Map<Class<?>,List<MessageHandlingMember<? super T>>> allCommandHandlerInterceptors()
      Gets all command handler interceptors per type in this aggregate hierarchy.
      Returns:
      a map of command handler interceptors per type
    • commandHandlerInterceptors

      default Stream<MessageHandlingMember<? super T>> commandHandlerInterceptors(Class<? extends T> type)
      Gets command handler interceptors for provided type in this aggregate hierarchy.
      Parameters:
      type - the aggregate type in this hierarchy
      Returns:
      a stream of command handler interceptors for provided type
    • allEventHandlers

      default Map<Class<?>,List<MessageHandlingMember<? super T>>> allEventHandlers()
      Gets all event handlers per type in this aggregate hierarchy.
      Returns:
      a map of event handlers per type
    • modelOf

      <C> EntityModel<C> modelOf(Class<? extends C> childEntityType)
      Get the EntityModel of an entity of type childEntityType in case it is the child of the modeled entity.
      Type Parameters:
      C - the type of the child entity
      Parameters:
      childEntityType - The class instance of the child entity type
      Returns:
      An EntityModel for the child entity
    • entityClass

      Class<? extends T> entityClass()
      Returns the class this model describes
      Returns:
      the class this model describes