Class EventTypeUpcaster
java.lang.Object
org.axonframework.serialization.upcasting.SingleEntryUpcaster<IntermediateEventRepresentation>
org.axonframework.serialization.upcasting.event.SingleEventUpcaster
org.axonframework.serialization.upcasting.event.EventTypeUpcaster
- All Implemented Interfaces:
EventUpcaster,Upcaster<IntermediateEventRepresentation>
A
SingleEventUpcaster implementation which allows for type upcasting only. This could be used if the event's
class name did not follow the desired naming convention or if an event's package name has been adjusted.
Note that this upcaster should not be used to change the semantic meaning of an event. Such a requirement points towards a new event type instead of adjusting an existing one.
- Since:
- 4.3
- Author:
- Steven van Beelen
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionEventTypeUpcaster(String expectedPayloadType, String expectedRevision, String upcastedPayloadType, String upcastedRevision) Instantiate anEventTypeUpcasterusing the given expected and upcasted payload types and revisions. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancanUpcast(IntermediateEventRepresentation intermediateRepresentation) Checks if this upcaster can upcast the givenintermediateRepresentation.protected IntermediateEventRepresentationdoUpcast(IntermediateEventRepresentation intermediateRepresentation) Upcasts the givenintermediateRepresentation.static EventTypeUpcaster.BuilderInstantiate aEventTypeUpcaster.Builderwhich should upcast "from" the givenpayloadTypeandrevision.static EventTypeUpcaster.BuilderInstantiate aEventTypeUpcaster.Builderwhich should upcast "from" the givenpayloadTypeandrevision.protected booleanisExpectedPayloadType(String payloadType) Check whether the givenpayloadTypematches the outcome ofexpectedPayloadType.protected booleanisExpectedRevision(String revision) Check whether the givenrevisionmatches the outcome ofexpectedRevision.protected SerializedTypeRetrieve the upcasted eventSerializedType.Methods inherited from class org.axonframework.serialization.upcasting.SingleEntryUpcaster
upcast
-
Constructor Details
-
EventTypeUpcaster
public EventTypeUpcaster(String expectedPayloadType, String expectedRevision, String upcastedPayloadType, String upcastedRevision) Instantiate anEventTypeUpcasterusing the given expected and upcasted payload types and revisions. Note that the payload type normally represents the fully qualified class name of the event to upcast.- Parameters:
expectedPayloadType- the expected event payload type this upcaster should react onexpectedRevision- the expected event revision this upcaster should react onupcastedPayloadType- the event payload type to upcast towardsupcastedRevision- the event revision to upcast towards
-
-
Method Details
-
from
Instantiate aEventTypeUpcaster.Builderwhich should upcast "from" the givenpayloadTypeandrevision. This method will use the fully qualified class name of the givenpayloadTypeas theexpectedPayloadType.- Parameters:
payloadType- the payload type the upcaster should upcast "from"revision- the revision the upcaster should upcast "from"- Returns:
- the current Builder instance, for fluent interfacing
-
from
Instantiate aEventTypeUpcaster.Builderwhich should upcast "from" the givenpayloadTypeandrevision.- Parameters:
payloadType- the payload type the upcaster should upcast "from"revision- the revision the upcaster should upcast "from"- Returns:
- the current Builder instance, for fluent interfacing
-
canUpcast
Description copied from class:SingleEntryUpcasterChecks if this upcaster can upcast the givenintermediateRepresentation. If the upcaster cannot upcast the representation theSingleEntryUpcaster.doUpcast(Object)is not invoked.- Specified by:
canUpcastin classSingleEntryUpcaster<IntermediateEventRepresentation>- Parameters:
intermediateRepresentation- the intermediate object representation to upcast- Returns:
trueif the representation can be upcast,falseotherwise
-
isExpectedPayloadType
Check whether the givenpayloadTypematches the outcome ofexpectedPayloadType.- Parameters:
payloadType- the event payload type received by this upcaster in thecanUpcast(IntermediateEventRepresentation)method- Returns:
trueif the givenpayloadTypematches the result ofexpectedPayloadType,falseotherwise
-
isExpectedRevision
Check whether the givenrevisionmatches the outcome ofexpectedRevision.- Parameters:
revision- the event payload type received by this upcaster in thecanUpcast(IntermediateEventRepresentation)method- Returns:
trueif the givenrevisionmatches the result ofexpectedRevision,falseotherwise
-
doUpcast
protected IntermediateEventRepresentation doUpcast(IntermediateEventRepresentation intermediateRepresentation) Description copied from class:SingleEntryUpcasterUpcasts the givenintermediateRepresentation. This method is only invoked ifSingleEntryUpcaster.canUpcast(Object)returnedtruefor the given representation.Note that the returned representation should not be
null. To remove an intermediateRepresentation add a filter to the input stream.- Specified by:
doUpcastin classSingleEntryUpcaster<IntermediateEventRepresentation>- Parameters:
intermediateRepresentation- the representation of the object to upcast- Returns:
- the upcasted representation
-
upcastedType
Retrieve the upcasted eventSerializedType. Returns aSimpleSerializedTypeusingupcastedPayloadTypeandupcastedRevisionas constructor inputs- Returns:
- the event
SerializedTypeto upcast to
-