Class StreamCollector<T>
java.lang.Object
org.jdrupes.builder.core.StreamCollector<T>
- Type Parameters:
T- the generic type
A StreamCollector allows the user to combine several Streams
into one. The collected streams are terminated when
stream() is called. If the collector is cached, stream() can
be invoked several times and each invocation returns a new Stream
with the collected content.
Note that cached collectors are implemented in a straightforward manner by putting all contents in a list and then returning a stream for the list.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal StreamCollector<T> Use all given streams as sources.final StreamCollector<T> Convenience method for adding a enumerated items.static <T> StreamCollector<T> cached()Create a cached collector.static <T> StreamCollector<T> Create a cached collector initially containing a single source stream.stream()Provide the contents from the stream(s).static <T> StreamCollector<T> uncached()Create an un-cached collector.static <T> StreamCollector<T> Create an un-cached collector initially containing a single source stream.
-
Constructor Details
-
StreamCollector
Instantiates a new collector.- Parameters:
cached- determines if contents is cached
-
-
Method Details
-
add
Use all given streams as sources.- Parameters:
sources- the sources- Returns:
- the stream collector
-
add
Convenience method for adding a enumerated items.- Parameters:
items- the item- Returns:
- the stream collector
-
stream
-
cached
Create a cached collector.- Type Parameters:
T- the generic type- Returns:
- the cached stream
-
cached
Create a cached collector initially containing a single source stream.- Type Parameters:
T- the generic type- Parameters:
source- the source- Returns:
- the cached stream
-
uncached
Create an un-cached collector.- Type Parameters:
T- the generic type- Returns:
- the cached stream
-
uncached
Create an un-cached collector initially containing a single source stream.- Type Parameters:
T- the generic type- Parameters:
source- the source- Returns:
- the cached stream
-