public abstract class SingleEntryUpcaster<T> extends Object implements Upcaster<T>
Upcasterthat 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.
|Constructor and Description|
|Modifier and Type||Method and Description|
Checks if this upcaster can upcast the given
Upcasts the given
Apply this upcaster to a stream of
public Stream<T> upcast(Stream<T> intermediateRepresentations)
intermediateRepresentationsand 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
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.
protected abstract boolean canUpcast(T intermediateRepresentation)
intermediateRepresentation. If the upcaster cannot upcast the representation the
doUpcast(Object)is not invoked.
intermediateRepresentation- the intermediate object representation to upcast
trueif the representation can be upcast,
protected abstract T doUpcast(T intermediateRepresentation)
intermediateRepresentation. This method is only invoked if
truefor the given representation.
Note that the returned representation should not be
null. To remove an intermediateRepresentation add a
filter to the input stream.
intermediateRepresentation- the representation of the object to upcast
Copyright © 2010–2022. All rights reserved.