Class StreamWrapper<T>
java.lang.Object
org.apache.sis.internal.stream.BaseStreamWrapper<T, Stream<T>>
org.apache.sis.internal.stream.StreamWrapper<T>
- Type Parameters:
T- the type of objects contained in the stream, as specified inStreaminterface.
- All Implemented Interfaces:
AutoCloseable, BaseStream<T, Stream<T>>, Stream<T>
- Direct Known Subclasses:
DeferredStream, PaginedStream
A stream which delegates all operations to another stream.
This stream gives to subclasses an opportunity to redirect some operations to optimized implementations.
Note:
It is sometimes necessary to defer the creation of the source stream until a terminal operation is invoked.
Such deferred source creation is managed by the DeferredStream subclass.
- Since:
- 1.1
- Version:
- 1.1
-
Nested Class Summary
Nested classes/interfaces inherited from interface Stream
Stream.Builder<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionThe source of elements, ornullif thisStreamWrapperis no longer the active stream.Fields inherited from class BaseStreamWrapper
toClose -
Constructor Summary
ConstructorsModifierConstructorDescription(package private)Creates a new wrapper with initially no source.protectedStreamWrapper(Stream<T> source) Creates a new wrapper for the given stream. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns whether all elements of this stream match the provided predicate.booleanReturns whether at least one element of this stream matches the provided predicate.<R> Rcollect(Supplier<R> supplier, BiConsumer<R, ? super T> accumulator, BiConsumer<R, R> combiner) Performs a mutable reduction on the elements of this stream.<R,A> R Performs a mutable reduction on the elements of this stream.longcount()Returns the number of elements in this stream.delegate()Same assource()but marks this stream is inactive.distinct()Returns a stream with distinct elements of this stream.Returns a stream with elements of this stream that match the given predicate.findAny()Returns any element of this stream.Returns the first element of this stream.<R> Stream<R> Returns a stream with results of applying the given function to the elements of this stream.flatMapToDouble(Function<? super T, ? extends DoubleStream> mapper) Returns a stream with results of applying the given function to the elements of this stream.flatMapToInt(Function<? super T, ? extends IntStream> mapper) Returns a stream with results of applying the given function to the elements of this stream.flatMapToLong(Function<? super T, ? extends LongStream> mapper) Returns a stream with results of applying the given function to the elements of this stream.voidPerforms an action for each element of this stream.voidforEachOrdered(Consumer<? super T> action) Performs an action for each element of this stream in encounter order.iterator()Returns an iterator for the elements of this stream.limit(long maxSize) Returns a stream with truncated at the given number of elements.<R> Stream<R> Returns a stream with results of applying the given function to the elements of this stream.mapToDouble(ToDoubleFunction<? super T> mapper) Returns a stream with results of applying the given function to the elements of this stream.mapToInt(ToIntFunction<? super T> mapper) Returns a stream with results of applying the given function to the elements of this stream.mapToLong(ToLongFunction<? super T> mapper) Returns a stream with results of applying the given function to the elements of this stream.max(Comparator<? super T> comparator) Returns the maximum element of this stream according to the provided comparator.min(Comparator<? super T> comparator) Returns the minimum element of this stream according to the provided comparator.booleanReturns whether none element of this stream match the provided predicate.Returns an equivalent stream with an additional close handler.parallel()Returns an equivalent stream that is parallel.Returns a stream performing the specified action on each element when consumed.reduce(BinaryOperator<T> accumulator) Performs a reduction on the elements of this stream.reduce(T identity, BinaryOperator<T> accumulator) Performs a reduction on the elements of this stream.<U> Ureduce(U identity, BiFunction<U, ? super T, U> accumulator, BinaryOperator<U> combiner) Performs a reduction on the elements of this stream.Returns an equivalent stream that is sequential.skip(long n) Returns a stream discarding the specified number of elements.sorted()Returns a stream with elements of this stream sorted in natural order.sorted(Comparator<? super T> comparator) Returns a stream with elements of this stream sorted using the given comparator.source()Verifies that this stream is still the active one, then returns the source of this stream.Returns a spliterator for the elements of this stream.Object[]toArray()Returns all elements in an array.<A> A[]toArray(IntFunction<A[]> generator) Returns all elements in an array.Returns an equivalent stream that is unordered.Invoked after an intermediate operation for determining which stream is the active one.Methods inherited from class BaseStreamWrapper
close, inactive, isParallelMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface BaseStream
close, isParallel
-
Field Details
-
source
-
-
Constructor Details
-
StreamWrapper
StreamWrapper()Creates a new wrapper with initially no source. Thesourcefield should be initialized by subclass constructor. -
StreamWrapper
-
-
Method Details
-
source
Verifies that this stream is still the active one, then returns the source of this stream.- Specified by:
sourcein classBaseStreamWrapper<T, Stream<T>>- Returns:
- the stream containing actual data.
- Throws:
IllegalStateException- if this stream is no longer the active stream on which to apply operations.
-
delegate
Same assource()but marks this stream is inactive. All subsequent operations must be done on the returned stream. This is used by this class formap(…)andflatMap(…)operations. May also be used by subclasses when an operation does not allow further optimizations.- Returns:
- the stream containing actual data.
- Throws:
IllegalStateException- if this stream is no longer the active stream on which to apply operations.
-
update
-
parallel
-
sequential
Returns an equivalent stream that is sequential.- Specified by:
sequentialin interfaceBaseStream<T, Stream<T>>
-
unordered
-
filter
-
map
-
mapToInt
-
mapToLong
Returns a stream with results of applying the given function to the elements of this stream. -
mapToDouble
Returns a stream with results of applying the given function to the elements of this stream.- Specified by:
mapToDoublein interfaceStream<T>
-
flatMap
-
flatMapToInt
-
flatMapToLong
Returns a stream with results of applying the given function to the elements of this stream.- Specified by:
flatMapToLongin interfaceStream<T>
-
flatMapToDouble
Returns a stream with results of applying the given function to the elements of this stream.- Specified by:
flatMapToDoublein interfaceStream<T>
-
distinct
-
sorted
-
sorted
-
peek
-
limit
-
skip
-
forEach
-
forEachOrdered
Performs an action for each element of this stream in encounter order.- Specified by:
forEachOrderedin interfaceStream<T>
-
reduce
-
reduce
-
reduce
public <U> U reduce(U identity, BiFunction<U, ? super T, U> accumulator, BinaryOperator<U> combiner) Performs a reduction on the elements of this stream. -
collect
public <R> R collect(Supplier<R> supplier, BiConsumer<R, ? super T> accumulator, BiConsumer<R, R> combiner) Performs a mutable reduction on the elements of this stream. -
collect
-
min
-
max
-
count
-
anyMatch
-
allMatch
-
noneMatch
-
findFirst
-
findAny
-
iterator
-
spliterator
Returns a spliterator for the elements of this stream.- Specified by:
spliteratorin interfaceBaseStream<T, Stream<T>>
-
toArray
-
toArray
Returns all elements in an array. -
onClose
-