public class EventTypeUpcaster extends SingleEventUpcaster
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.
| Modifier and Type | Class and Description |
|---|---|
static class |
EventTypeUpcaster.Builder
Builder class to instantiate an
EventTypeUpcaster. |
| Constructor and Description |
|---|
EventTypeUpcaster(String expectedPayloadType,
String expectedRevision,
String upcastedPayloadType,
String upcastedRevision)
Instantiate an
EventTypeUpcaster using the given expected and upcasted payload types and revisions. |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
canUpcast(IntermediateEventRepresentation intermediateRepresentation)
Checks if this upcaster can upcast the given
intermediateRepresentation. |
protected IntermediateEventRepresentation |
doUpcast(IntermediateEventRepresentation intermediateRepresentation)
Upcasts the given
intermediateRepresentation. |
static EventTypeUpcaster.Builder |
from(Class<?> payloadType,
String revision)
Instantiate a
EventTypeUpcaster.Builder which should upcast "from" the given payloadType and
revision. |
static EventTypeUpcaster.Builder |
from(String payloadType,
String revision)
Instantiate a
EventTypeUpcaster.Builder which should upcast "from" the given payloadType and
revision. |
protected boolean |
isExpectedPayloadType(String payloadType)
Check whether the given
payloadType matches the outcome of expectedPayloadType. |
protected boolean |
isExpectedRevision(String revision)
Check whether the given
revision matches the outcome of expectedRevision. |
protected SerializedType |
upcastedType()
Retrieve the upcasted event
SerializedType. |
upcastpublic EventTypeUpcaster(String expectedPayloadType, String expectedRevision, String upcastedPayloadType, String upcastedRevision)
EventTypeUpcaster using 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.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 towardspublic static EventTypeUpcaster.Builder from(Class<?> payloadType, String revision)
EventTypeUpcaster.Builder which should upcast "from" the given payloadType and
revision. This method will use the fully qualified class name of the given payloadType as the
expectedPayloadType.payloadType - the payload type the upcaster should upcast "from"revision - the revision the upcaster should upcast "from"public static EventTypeUpcaster.Builder from(String payloadType, String revision)
EventTypeUpcaster.Builder which should upcast "from" the given payloadType and
revision.payloadType - the payload type the upcaster should upcast "from"revision - the revision the upcaster should upcast "from"protected boolean canUpcast(IntermediateEventRepresentation intermediateRepresentation)
SingleEntryUpcasterintermediateRepresentation. If the upcaster cannot upcast
the representation the SingleEntryUpcaster.doUpcast(Object) is not invoked.canUpcast in class SingleEntryUpcaster<IntermediateEventRepresentation>intermediateRepresentation - the intermediate object representation to upcasttrue if the representation can be upcast, false otherwiseprotected boolean isExpectedPayloadType(String payloadType)
payloadType matches the outcome of expectedPayloadType.payloadType - the event payload type received by this upcaster in the canUpcast(IntermediateEventRepresentation)
methodtrue if the given payloadType matches the result of expectedPayloadType, false otherwiseprotected boolean isExpectedRevision(String revision)
revision matches the outcome of expectedRevision.revision - the event payload type received by this upcaster in the canUpcast(IntermediateEventRepresentation)
methodtrue if the given revision matches the result of expectedRevision, false
otherwiseprotected IntermediateEventRepresentation doUpcast(IntermediateEventRepresentation intermediateRepresentation)
SingleEntryUpcasterintermediateRepresentation. This method is only invoked if SingleEntryUpcaster.canUpcast(Object)
returned true for the given representation.
Note that the returned representation should not be null. To remove an intermediateRepresentation add a
filter to the input stream.
doUpcast in class SingleEntryUpcaster<IntermediateEventRepresentation>intermediateRepresentation - the representation of the object to upcastprotected SerializedType upcastedType()
SerializedType. Returns a SimpleSerializedType using upcastedPayloadType and upcastedRevision as constructor inputsSerializedType to upcast toCopyright © 2010–2025. All rights reserved.