Class ContextAwareSingleEntryMultiUpcaster<T,C>
java.lang.Object
org.axonframework.serialization.upcasting.ContextAwareSingleEntryMultiUpcaster<T,C>
- Type Parameters:
T- the type of entry to be upcasted asTC- the type of context used asC
- All Implemented Interfaces:
Upcaster<T>
- Direct Known Subclasses:
ContextAwareEventMultiUpcaster
public abstract class ContextAwareSingleEntryMultiUpcaster<T,C>
extends Object
implements Upcaster<T>
Abstract implementation of an
Upcaster that eases the common process of upcasting one intermediate
representation to several other representations by applying a simple flat mapping function to the input stream of
intermediate representations. Additionally, it's a context aware implementation, which enables it to store and reuse
context information from one entry to another during upcasting.- Since:
- 3.1
- Author:
- Steven van Beelen
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract CBuilds a context of generic typeCto be used when processing the stream of intermediate object representationsT.protected abstract booleanChecks if this upcaster can upcast the givenintermediateRepresentation.Upcasts the givenintermediateRepresentation.Apply this upcaster to a stream ofintermediateRepresentationsand return the altered stream.
-
Constructor Details
-
ContextAwareSingleEntryMultiUpcaster
public ContextAwareSingleEntryMultiUpcaster()
-
-
Method Details
-
upcast
Description copied from interface:UpcasterApply this upcaster to a stream ofintermediateRepresentationsand return the altered stream.To upcast an object an upcaster should apply a mapping function to the input stream (
Stream.map(java.util.function.Function)). To remove an object from the stream the upcaster should filter the input stream (Stream.filter(java.util.function.Predicate)). To split an input object into more than one objects useStream.flatMap(java.util.function.Function).In some cases the upcasting result of an Upcaster may depend on more than one input object. In that case an Upcaster may store state in the method during upcasting or even read ahead in the stream.
-
canUpcast
Checks if this upcaster can upcast the givenintermediateRepresentation. If the upcaster cannot upcast the representation thedoUpcast(Object, Object)is not invoked. Thecontextcan be used to store or retrieve entry specific information required to make thecanUpcast(Object, Object)check.- Parameters:
intermediateRepresentation- the intermediate object representation to upcast asTcontext- the context for this upcaster asC- Returns:
trueif the representation can be upcast,falseotherwise
-
doUpcast
Upcasts the givenintermediateRepresentation. This method is only invoked ifcanUpcast(Object, Object)returnedtruefor the given representation. Thecontextcan be used to store or retrieve entry specific information required to perform the upcasting process.Note that the returned representation should not be
null. To remove an intermediateRepresentation add a filter to the input stream.- Parameters:
intermediateRepresentation- the representation of the object to upcast asTcontext- the context for this upcaster asC- Returns:
- the upcasted representations as a
Streamwith generic typeT
-
buildContext
Builds a context of generic typeCto be used when processing the stream of intermediate object representationsT.- Returns:
- a context of generic type
C
-