Class SimpleEntityEvolvingComponent<E>

java.lang.Object
org.axonframework.modelling.SimpleEntityEvolvingComponent<E>
Type Parameters:
E - The entity type to evolve.
All Implemented Interfaces:
DescribableComponent, EntityEvolver<E>, EntityEvolvingComponent<E>

public class SimpleEntityEvolvingComponent<E> extends Object implements EntityEvolvingComponent<E>, DescribableComponent
Implementation of EntityEvolvingComponent that evolves a given entity of type E by searching a specific EntityEvolver based on the QualifiedName in the event's type.
Since:
5.0.0
Author:
Mitchell Herrijgers, Steven van Beelen
  • Constructor Details

    • SimpleEntityEvolvingComponent

      public SimpleEntityEvolvingComponent(@Nonnull Map<QualifiedName,EntityEvolver<E>> entityEvolvers)
      Constructs a SimpleEntityEvolvingComponent that evolves an entity of type e through the given entityEvolvers.
      Parameters:
      entityEvolvers - The map of EntityEvolver instance to QualifiedName to evolve an entity through.
  • Method Details

    • evolve

      public E evolve(@Nonnull E entity, @Nonnull EventMessage event, @Nonnull ProcessingContext context)
      Description copied from interface: EntityEvolver
      Evolve the given entity by applying the given event to it.
      Specified by:
      evolve in interface EntityEvolver<E>
      Parameters:
      entity - The current entity to evolve with the given event.
      event - The event that might adjust the entity.
      context - The context within which to evolve the entity by the given event.
      Returns:
      The evolved entity based on the given event, or the same entity when nothing happened.
    • supportedEvents

      @Nonnull public Set<QualifiedName> supportedEvents()
      Description copied from interface: EntityEvolvingComponent
      All supported events, referenced through a QualifiedName.
      Specified by:
      supportedEvents in interface EntityEvolvingComponent<E>
      Returns:
      All supported events, referenced through a QualifiedName.
    • describeTo

      public void describeTo(@Nonnull ComponentDescriptor descriptor)
      Description copied from interface: DescribableComponent
      Describe the properties of this DescribableComponent with the given descriptor.

      Components should call the appropriate describeProperty methods on the descriptor to register their properties. The descriptor is responsible for determining how these properties are formatted and structured in the final output.

      Best Practices: As a general rule, all relevant fields of a DescribableComponent implementation should be described in this method. However, developers have discretion to include only the fields that make sense in the context. Not every field may be meaningful for description purposes, especially internal implementation details. Furthermore, components might want to expose different information based on their current state. The final decision on what properties to include lies with the person implementing the describeTo method, who should focus on providing information that is useful for understanding the component's configuration and state.

      Example implementation:

       public void describeTo(ComponentDescriptor descriptor) {
           descriptor.describeProperty("name", this.name);
           descriptor.describeProperty("enabled", this.enabled);
           descriptor.describeProperty("configuration", this.configuration); // A nested component
           descriptor.describeProperty("handlers", this.eventHandlers);      // A collection
       }
       
      Specified by:
      describeTo in interface DescribableComponent
      Parameters:
      descriptor - The component descriptor to describe this DescribableComponentn its properties in.