org.axonframework.upcasting
Interface Upcaster<T>

Type Parameters:
T - The data format that this upcaster uses to represent the event
All Known Subinterfaces:
ExtendedUpcaster<T>
All Known Implementing Classes:
AbstractSingleEntryUpcaster, RunUpcaster.ToDoItemUpcaster

public interface Upcaster<T>

Interface for Upcasters. An upcaster is the mechanism used to convert deprecated (typically serialized) objects and convert them into the current format. If the serializer itself is not able to cope with the changed formats (XStream, for example, will allow for some changes by using aliases), the Upcaster will allow you to configure more complex structural transformations.

Upcasters work on intermediate representations of the object to upcast. In some cases, this representation is a byte array, while in other cases an object structure is used. The Serializer is responsible for converting the intermediate representation form to one that is compatible with the upcaster. For performance reasons, it is advisable to ensure that all upcasters in the same chain (where one's output is another's input) use the same intermediate representation type.

Since:
2.0
Author:
Allard Buijze, Frank Versnel

Method Summary
 boolean canUpcast(SerializedType serializedType)
          Indicates whether this upcaster is capable of upcasting the given type.
 Class<T> expectedRepresentationType()
          Returns the type of intermediate representation this upcaster expects.
 List<SerializedObject<?>> upcast(SerializedObject<T> intermediateRepresentation, List<SerializedType> expectedTypes, UpcastingContext context)
          Upcasts the given intermediateRepresentation into zero or more other representations.
 List<SerializedType> upcast(SerializedType serializedType)
          Upcast the given serializedType into its new format.
 

Method Detail

canUpcast

boolean canUpcast(SerializedType serializedType)
Indicates whether this upcaster is capable of upcasting the given type. Unless this method returns true, the upcast(org.axonframework.serializer.SerializedType) and upcast(org.axonframework.serializer.SerializedType) methods should not be invoked on this Upcaster instance.

Parameters:
serializedType - The type under investigation
Returns:
true if this upcaster can upcast the given serialized type, false otherwise.

expectedRepresentationType

Class<T> expectedRepresentationType()
Returns the type of intermediate representation this upcaster expects. The serializer must ensure the intermediate representation is offered in a compatible format.

Returns:
the type of intermediate representation expected

upcast

List<SerializedObject<?>> upcast(SerializedObject<T> intermediateRepresentation,
                                 List<SerializedType> expectedTypes,
                                 UpcastingContext context)
Upcasts the given intermediateRepresentation into zero or more other representations. The returned list of Serialized Objects must match the given list of serialized types.

Parameters:
intermediateRepresentation - The representation of the object to upcast
expectedTypes - The expected types of the returned serialized objects.
context - An instance describing the context of the object to upcast
Returns:
the new representations of the object

upcast

List<SerializedType> upcast(SerializedType serializedType)
Upcast the given serializedType into its new format. Generally, this involves increasing the revision. Sometimes, it is also necessary to alter the type's name (in case of a renamed class, for example). The order and the size of the list returned has to match with the order and size of the list of the upcast IntermediateRepresentations by this upcaster.

To base the type on the actual contents of the Serialized Object, implement the ExtendedUpcaster interface instead.

Parameters:
serializedType - The serialized type to upcast
Returns:
the upcast serialized type
See Also:
ExtendedUpcaster.upcast(org.axonframework.serializer.SerializedType, org.axonframework.serializer.SerializedObject)


Copyright © 2010-2016. All Rights Reserved.