Package com.valqueries
Class StreamCloser<T>
java.lang.Object
com.valqueries.StreamCloser<T>
- All Implemented Interfaces:
- AutoCloseable,- BaseStream<T,,- Stream<T>> - Stream<T>
Stream wrapper that calls close() on terminal operations. Mapping to primitive streams causes the underlying stream
 to collect to a list and close, as we need to ensure that the underlying resource is closed.
- 
Nested Class SummaryNested classes/interfaces inherited from interface java.util.stream.StreamStream.Builder<T extends Object>
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionbooleanbooleanvoidclose()<R> Rcollect(Supplier<R> supplier, BiConsumer<R, ? super T> biConsumer, BiConsumer<R, R> biConsumer1) <R,A> R longcount()distinct()findAny()<R> Stream<R>flatMapToDouble(Function<? super T, ? extends DoubleStream> function) flatMapToInt(Function<? super T, ? extends IntStream> function) flatMapToLong(Function<? super T, ? extends LongStream> function) voidvoidforEachOrdered(Consumer<? super T> consumer) booleaniterator()limit(long l) <R> Stream<R><R> Stream<R>mapMulti(BiConsumer<? super T, ? super Consumer<R>> mapper) mapMultiToDouble(BiConsumer<? super T, ? super DoubleConsumer> mapper) mapMultiToInt(BiConsumer<? super T, ? super IntConsumer> mapper) mapMultiToLong(BiConsumer<? super T, ? super LongConsumer> mapper) mapToDouble(ToDoubleFunction<? super T> toDoubleFunction) mapToInt(ToIntFunction<? super T> toIntFunction) mapToLong(ToLongFunction<? super T> toLongFunction) max(Comparator<? super T> comparator) min(Comparator<? super T> comparator) booleanWorks the same as the baseBaseStream.onClose(Runnable)but note that the `StreamCloser` may in some circumstances close and create a new backing list for some operations.parallel()reduce(BinaryOperator<T> binaryOperator) reduce(T t, BinaryOperator<T> binaryOperator) <U> Ureduce(U u, BiFunction<U, ? super T, U> biFunction, BinaryOperator<U> binaryOperator) skip(long l) sorted()sorted(Comparator<? super T> comparator) Object[]toArray()<A> A[]toArray(IntFunction<A[]> intFunction) toList()
- 
Constructor Details- 
StreamCloser
 
- 
- 
Method Details- 
filter
- 
map
- 
mapToInt
- 
mapToLong
- 
mapToDouble- Specified by:
- mapToDoublein interface- Stream<T>
 
- 
flatMap
- 
flatMapToInt- Specified by:
- flatMapToIntin interface- Stream<T>
 
- 
flatMapToLong- Specified by:
- flatMapToLongin interface- Stream<T>
 
- 
flatMapToDouble- Specified by:
- flatMapToDoublein interface- Stream<T>
 
- 
mapMulti
- 
mapMultiToInt- Specified by:
- mapMultiToIntin interface- Stream<T>
 
- 
mapMultiToLong- Specified by:
- mapMultiToLongin interface- Stream<T>
 
- 
mapMultiToDouble- Specified by:
- mapMultiToDoublein interface- Stream<T>
 
- 
distinct
- 
sorted
- 
sorted
- 
peek
- 
limit
- 
skip
- 
takeWhile
- 
dropWhile
- 
forEach
- 
forEachOrdered- Specified by:
- forEachOrderedin interface- Stream<T>
 
- 
toArray
- 
toArray
- 
reduce
- 
reduce
- 
reduce
- 
collectpublic <R> R collect(Supplier<R> supplier, BiConsumer<R, ? super T> biConsumer, BiConsumer<R, R> biConsumer1) 
- 
collect
- 
toList
- 
min
- 
max
- 
countpublic long count()
- 
anyMatch
- 
allMatch
- 
noneMatch
- 
findFirst
- 
findAny
- 
iterator- Specified by:
- iteratorin interface- BaseStream<T,- Stream<T>> 
 
- 
nonClosingIterator- Returns:
- an iterator that does not close the stream. Make sure this stream is closed after the iterator is used.
 
- 
spliterator- Specified by:
- spliteratorin interface- BaseStream<T,- Stream<T>> 
 
- 
isParallelpublic boolean isParallel()- Specified by:
- isParallelin interface- BaseStream<T,- Stream<T>> 
 
- 
sequential- Specified by:
- sequentialin interface- BaseStream<T,- Stream<T>> 
 
- 
parallel- Specified by:
- parallelin interface- BaseStream<T,- Stream<T>> 
 
- 
unordered- Specified by:
- unorderedin interface- BaseStream<T,- Stream<T>> 
 
- 
onCloseWorks the same as the baseBaseStream.onClose(Runnable)but note that the `StreamCloser` may in some circumstances close and create a new backing list for some operations. As such any runnable bound in this way is only guaranteed to be run after any operations which were specified before it was bound.E.g. the following code may produce different execution timings for `x`, depending on the underlying stream source: 
 compared tostream.onClose(x).mapToInt(mapper);stream.mapToInt(mapper).onClose(x);- Specified by:
- onClosein interface- BaseStream<T,- Stream<T>> 
- Parameters:
- runnable- A task to execute when the stream is closed
- Returns:
- a stream with a handler that is run if the stream is closed
 
- 
closepublic void close()- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- BaseStream<T,- Stream<T>> 
 
 
-