Class SingleEntryUpcaster<T>

java.lang.Object
org.axonframework.serialization.upcasting.SingleEntryUpcaster<T>
All Implemented Interfaces:
Upcaster<T>
Direct Known Subclasses:
SingleEventUpcaster

public abstract class SingleEntryUpcaster<T> extends Object implements Upcaster<T>
Abstract implementation of an Upcaster that eases the common process of upcasting one intermediate representation to another representation by applying a simple mapping function to the input stream of intermediate representations.
Since:
3.0
Author:
Rene de Waele
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract boolean
    canUpcast(T intermediateRepresentation)
    Checks if this upcaster can upcast the given intermediateRepresentation.
    protected abstract T
    doUpcast(T intermediateRepresentation)
    Upcasts the given intermediateRepresentation.
    upcast(Stream<T> intermediateRepresentations)
    Apply this upcaster to a stream of intermediateRepresentations and return the altered stream.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SingleEntryUpcaster

      public SingleEntryUpcaster()
  • Method Details

    • upcast

      public Stream<T> upcast(Stream<T> intermediateRepresentations)
      Description copied from interface: Upcaster
      Apply this upcaster to a stream of intermediateRepresentations and 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 use Stream.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.

      Specified by:
      upcast in interface Upcaster<T>
      Parameters:
      intermediateRepresentations - The input stream of representations of objects
      Returns:
      the output stream of representations after applying the upcast function
    • canUpcast

      protected abstract boolean canUpcast(T intermediateRepresentation)
      Checks if this upcaster can upcast the given intermediateRepresentation. If the upcaster cannot upcast the representation the doUpcast(Object) is not invoked.
      Parameters:
      intermediateRepresentation - the intermediate object representation to upcast
      Returns:
      true if the representation can be upcast, false otherwise
    • doUpcast

      protected abstract T doUpcast(T intermediateRepresentation)
      Upcasts the given intermediateRepresentation. This method is only invoked if 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.

      Parameters:
      intermediateRepresentation - the representation of the object to upcast
      Returns:
      the upcasted representation