Class PayloadBasedEntityEvolver<P,E>

java.lang.Object
org.axonframework.modelling.PayloadBasedEntityEvolver<P,E>
Type Parameters:
P - The payload type of the event to apply.
E - The entity type to evolve.
All Implemented Interfaces:
EntityEvolver<E>

public class PayloadBasedEntityEvolver<P,E> extends Object implements EntityEvolver<E>
An EntityEvolver implementation that converts the Message.payload() to the given payloadType to evolve an entity with.

Will throw a ClassCastException if the payloadType does not match.

Since:
5.0.0
Author:
Mitchell Herrijgers
  • Constructor Details

    • PayloadBasedEntityEvolver

      public PayloadBasedEntityEvolver(@Nonnull Class<P> payloadType, @Nonnull BiFunction<E,P,E> evolver)
      Constructs a PayloadConvertingEntityEvolver, converting the Message.payload() to the given payloadType, after which it invokes the given evolver.

      If the Message.payload() cannot be converted to the requested payloadType, a ClassCastException is thrown.

      Parameters:
      payloadType - The payload type to check against.
      evolver - The function to evolve the entity with.
  • 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<P>
      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.