@@ -0,0 +1,1820 @@
+package org.axonframework.serialization.upcasting;%0A%0Aimport java.util.stream.Stream;%0A%0A/**%0A * Abstract implementation of an %7B@link Upcaster%7D that eases the common process of upcasting one intermediate%0A * representation to several other representations by applying a simple flat mapping function to the input stream of%0A * intermediate representations.%0A *%0A * @author Steven van Beelen%0A */%0Apublic abstract class MultiEntryUpcaster%3CT%3E implements Upcaster%3CT%3E %7B%0A%0A    @Override%0A    public Stream%3CT%3E upcast(Stream%3CT%3E intermediateRepresentations) %7B%0A        return intermediateRepresentations.flatMap(entry -%3E %7B%0A            if (!canUpcast(entry)) %7B%0A                return Stream.of(entry);%0A            %7D%0A            return doUpcast(entry);%0A        %7D);%0A    %7D%0A%0A    /**%0A     * Checks if this upcaster can upcast the given %7B@code intermediateRepresentation%7D.%0A     * If the upcaster cannot upcast the representation the %7B@link #doUpcast(T)%7D is not invoked.%0A     *%0A     * @param intermediateRepresentation the intermediate object representation to upcast%0A     * @return %7B@code true%7D if the representation can be upcast, %7B@code false%7D otherwise%0A     */%0A    protected abstract boolean canUpcast(T intermediateRepresentation);%0A%0A    /**%0A     * Upcasts the given %7B@code intermediateRepresentation%7D.%0A     * This method is only invoked if %7B@link #canUpcast(T)%7D returned %7B@code true%7D for the given representation.%0A     * %3Cp%3E%0A     * Note that the returned representation should not be %7B@code null%7D.%0A     * To remove an intermediateRepresentation add a filter to the input stream.%0A     *%0A     * @param intermediateRepresentation the representation of the object to upcast%0A     * @return the upcasted representations as a %7B@code Stream%7D with generic type %7B@code T%7D%0A     */%0A    protected abstract Stream%3CT%3E doUpcast(T intermediateRepresentation);%0A%0A%7D%0A

Add a MultiEntryUpcaster, similar to the SingleEntryUpcaster but doing a flatMap() rather than a map()