Package org.axonframework.modelling
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>
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 Summary
ConstructorsConstructorDescriptionPayloadBasedEntityEvolver(Class<P> payloadType, BiFunction<E, P, E> evolver) Constructs aPayloadConvertingEntityEvolver, converting theMessage.payload()to the givenpayloadType, after which it invokes the givenevolver. -
Method Summary
Modifier and TypeMethodDescriptionevolve(E entity, EventMessage event, ProcessingContext context) Evolve the givenentityby applying the giveneventto it.
-
Constructor Details
-
PayloadBasedEntityEvolver
Constructs aPayloadConvertingEntityEvolver, converting theMessage.payload()to the givenpayloadType, after which it invokes the givenevolver.If the
Message.payload()cannot be converted to the requestedpayloadType, aClassCastExceptionis thrown.- Parameters:
payloadType- The payload type to check against.evolver- The function to evolve the entity with.
-
-
Method Details
-
evolve
Description copied from interface:EntityEvolverEvolve the givenentityby applying the giveneventto it.- Specified by:
evolvein interfaceEntityEvolver<P>- Parameters:
entity- The current entity to evolve with the givenevent.event- The event that might adjust theentity.context- The context within which to evolve theentityby the givenevent.- Returns:
- The evolved
entitybased on the givenevent, or the sameentitywhen nothing happened.
-