org.axonframework.upcasting
Class AbstractSingleEntryUpcaster<T>

java.lang.Object
  extended by org.axonframework.upcasting.AbstractSingleEntryUpcaster<T>
Type Parameters:
T - The data format that this upcaster uses to represent the event
All Implemented Interfaces:
Upcaster<T>
Direct Known Subclasses:
RunUpcaster.ToDoItemUpcaster

public abstract class AbstractSingleEntryUpcaster<T>
extends Object
implements Upcaster<T>

Abstract implementation of an upcaster that only needs to convert one serialized object to another using the same representation.

This class is not suitable when an upcaster needs to convert a single serialized object to multiple new serialized objects, or when the output representation type is not the same as the expected input representation type.

Since:
2.0
Author:
Allard Buijze

Constructor Summary
AbstractSingleEntryUpcaster()
           
 
Method Summary
protected abstract  T doUpcast(SerializedObject<T> intermediateRepresentation, UpcastingContext context)
          Upcasts the given intermediateRepresentation into zero or more other representations.
protected abstract  SerializedType doUpcast(SerializedType serializedType)
          Upcast the given serializedType into its new format.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.axonframework.upcasting.Upcaster
canUpcast, expectedRepresentationType
 

Constructor Detail

AbstractSingleEntryUpcaster

public AbstractSingleEntryUpcaster()
Method Detail

upcast

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

Specified by:
upcast in interface Upcaster<T>
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

public final List<SerializedType> upcast(SerializedType serializedType)
Description copied from interface: Upcaster
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.

Specified by:
upcast in interface Upcaster<T>
Parameters:
serializedType - The serialized type to upcast
Returns:
the upcast serialized type
See Also:
ExtendedUpcaster.upcast(org.axonframework.serializer.SerializedType, org.axonframework.serializer.SerializedObject)

doUpcast

protected abstract T doUpcast(SerializedObject<T> intermediateRepresentation,
                              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.

This method may return null to indicate a deprecated object.

Parameters:
intermediateRepresentation - The representation of the object to upcast
context - An instance describing the context of the object to upcast
Returns:
the new representation of the object

doUpcast

protected abstract SerializedType doUpcast(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).

If null is returned, the Serialized object of this type is considered deprecated and will not be subject to upcasting.

Parameters:
serializedType - The serialized type to upcast
Returns:
the upcast serialized type


Copyright © 2010-2016. All Rights Reserved.