public class GenericUpcasterChain<T> extends Object implements Upcaster<T>
Upcaster
that is formed of a chain of other upcasters which are combined to upcast a
stream of intermediate objects.Constructor and Description |
---|
GenericUpcasterChain(List<? extends Upcaster<T>> upcasters)
Initializes an upcaster chain from the given list of upcasters.
|
GenericUpcasterChain(Upcaster<T>... upcasters)
Initializes an upcaster chain from one or more upcasters.
|
Modifier and Type | Method and Description |
---|---|
protected List<? extends Upcaster<T>> |
getUpcasters()
Returns the list of
upcasters that makes up this chain. |
Stream<T> |
upcast(Stream<T> initialRepresentations)
Apply this upcaster to a stream of
intermediateRepresentations and return the altered stream. |
@SafeVarargs public GenericUpcasterChain(Upcaster<T>... upcasters)
upcasters
- the upcasters to chainpublic Stream<T> upcast(Stream<T> initialRepresentations)
Upcaster
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.
Copyright © 2010–2023. All rights reserved.