Interface EntityChildMetamodel<C,P>

Type Parameters:
C - The type of the child entity.
P - The type of the parent entity.
All Superinterfaces:
EntityEvolver<P>
All Known Implementing Classes:
AbstractEntityChildMetamodel, ListEntityChildMetamodel, SingleEntityChildMetamodel

public interface EntityChildMetamodel<C,P> extends EntityEvolver<P>
Interface describing a child EntityMetamodel that can be handled in the context of its parent. Handling commands for this metamodel is done in the context of the parent. This metamodel resolves the child from the given parent and can then invoke the right child instance to handle the command.
Since:
5.0.0
Author:
Mitchell Herrijgers
  • Method Details

    • supportedCommands

      @Nonnull Set<QualifiedName> supportedCommands()
      Returns the set of all QualifiedNames that this metamodel supports for command handlers.
      Returns:
      A set of QualifiedName instances representing the supported command names.
    • canHandle

      boolean canHandle(@Nonnull CommandMessage message, @Nonnull P parentEntity, @Nonnull ProcessingContext context)
      Checks if this child can handle the given CommandMessage for the given parent entity, and a child entity is available to handle it.
      Parameters:
      message - The CommandMessage to check.
      parentEntity - The parent entity instance to check against.
      context - The ProcessingContext for the command.
      Returns:
      true if this child can handle the command, false otherwise.
    • handle

      @Nonnull MessageStream.Single<CommandResultMessage> handle(@Nonnull CommandMessage message, @Nonnull P parentEntity, @Nonnull ProcessingContext context)
      Handles the given CommandMessage for the given child entity, using the provided parent entity.
      Parameters:
      message - The CommandMessage to handle.
      parentEntity - The child entity instance to handle the command for.
      context - The ProcessingContext for the command.
      Returns:
      The result of the command handling, which may be a CommandResultMessage or an error message.
    • entityType

      @Nonnull Class<C> entityType()
      Returns the Class of the child entity this metamodel describes.
      Returns:
      The Class of the child entity this metamodel describes.
    • entityMetamodel

      @Nonnull EntityMetamodel<C> entityMetamodel()
      Returns the EntityMetamodel of the child entity this metamodel describes.
      Returns:
      The EntityMetamodel of the child entity this metamodel describes.
    • single

      @Nonnull static <C, P> SingleEntityChildMetamodel.Builder<C,P> single(@Nonnull Class<P> parentClass, @Nonnull EntityMetamodel<C> metamodel)
      Starts a builder for a single child entity within the given parent entity type.
      Type Parameters:
      C - The type of the child entity.
      P - The type of the parent entity.
      Parameters:
      parentClass - The class of the parent entity.
      metamodel - The EntityMetamodel of the child entity.
      Returns:
      A SingleEntityChildMetamodel.Builder for the child entity.
    • list

      @Nonnull static <C, P> ListEntityChildMetamodel.Builder<C,P> list(@Nonnull Class<P> parentClass, @Nonnull EntityMetamodel<C> metamodel)
      Starts a builder for a list of child entities within the given parent entity type.
      Type Parameters:
      C - The type of the child entity.
      P - The type of the parent entity.
      Parameters:
      parentClass - The class of the parent entity.
      metamodel - The EntityMetamodel of the child entity.
      Returns:
      A ListEntityChildMetamodel.Builder for the child entity.