T
- the type of the stream elementsS
- the type of the stream implementing BaseStream
public interface BaseStream<T,S extends BaseStream<T,S>> extends AutoCloseable
Stream
and IntStream
, computing the sum of the weights of the red widgets:
int sum = widgets.stream()
.filter(w -> w.getColor() == RED)
.mapToInt(w -> w.getWeight())
.sum();
See the class documentation for Stream
and the package documentation
for java.util.stream for additional
specification of streams, stream operations, stream pipelines, and
parallelism, which governs the behavior of all stream types.Stream
,
IntStream
,
LongStream
,
DoubleStream
,
java.util.streamModifier and Type | Method and Description |
---|---|
void |
close()
Closes this stream, causing all close handlers for this stream pipeline
to be called.
|
boolean |
isParallel()
Returns whether this stream, if a terminal operation were to be executed,
would execute in parallel.
|
Iterator<T> |
iterator()
Returns an iterator for the elements of this stream.
|
S |
onClose(Runnable closeHandler)
Returns an equivalent stream with an additional close handler.
|
S |
parallel()
Returns an equivalent stream that is parallel.
|
S |
sequential()
Returns an equivalent stream that is sequential.
|
Spliterator<T> |
spliterator()
Returns a spliterator for the elements of this stream.
|
S |
unordered()
Returns an equivalent stream that is
unordered.
|
Iterator<T> iterator()
This is a terminal operation.
Spliterator<T> spliterator()
This is a terminal operation.
boolean isParallel()
true
if this stream would execute in parallel if executedS sequential()
This is an intermediate operation.
S parallel()
This is an intermediate operation.
S unordered()
This is an intermediate operation.
S onClose(Runnable closeHandler)
close()
method
is called on the stream, and are executed in the order they were
added. All close handlers are run, even if earlier close handlers throw
exceptions. If any close handler throws an exception, the first
exception thrown will be relayed to the caller of close()
, with
any remaining exceptions added to that exception as suppressed exceptions
(unless one of the remaining exceptions is the same exception as the
first exception, since an exception cannot suppress itself.) May
return itself.
This is an intermediate operation.
closeHandler
- A task to execute when the stream is closedvoid close()
close
in interface AutoCloseable
AutoCloseable.close()
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2019, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.