APIdia Launch Partner
Top Description Fields Constructors Methods
java.util.stream

pack-priv abstract Class AbstractPipeline<E_IN, E_OUT, S extends BaseStream<E_OUT, S>>

extends PipelineHelper<E_OUT>
implements BaseStream<E_OUT, S extends BaseStream<E_OUT, S>>
Class Inheritance
All Implemented Interfaces
java.util.stream.BaseStream, java.lang.AutoCloseable
Known Direct Subclasses
java.util.stream.DoublePipeline, java.util.stream.IntPipeline, java.util.stream.ReferencePipeline, java.util.stream.LongPipeline
Type Parameters
<E_IN>
type of input elements
<E_OUT>
type of output elements
<S>
type of the subclass implementing BaseStream
Imports
java.util.Objects, .Spliterator, java.util.function.IntFunction, .Supplier

Abstract base class for "pipeline" classes, which are the core implementations of the Stream interface and its primitive specializations. Manages construction and evaluation of stream pipelines.

An AbstractPipeline represents an initial portion of a stream pipeline, encapsulating a stream source and zero or more intermediate operations. The individual AbstractPipeline objects are often referred to as stages, where each stage describes either the stream source or an intermediate operation.

A concrete intermediate stage is generally built from an AbstractPipeline, a shape-specific pipeline class which extends it (e.g., IntPipeline) which is also abstract, and an operation-specific concrete class which extends that. AbstractPipeline contains most of the mechanics of evaluating the pipeline, and implements methods that will be used by the operation; the shape-specific classes add helper methods for dealing with collection of results into the appropriate shape-specific containers.

After chaining a new intermediate operation, or executing a terminal operation, the stream is considered to be consumed, and no more intermediate or terminal operations are permitted on this stream instance.

Implementation Note

For sequential streams, and parallel streams without stateful intermediate operations, parallel streams, pipeline evaluation is done in a single pass that "jams" all the operations together. For parallel streams with stateful operations, execution is divided into segments, where each stateful operations marks the end of a segment, and each segment is evaluated separately and the result used as the input to the next segment. In all cases, the source data is not consumed until a terminal operation begins.

Since
1.8

Field Summary

Modifier and TypeField and Description
private int
combinedFlags

The combined source and operation flags for the source and all operations up to and including the operation represented by this pipeline object.

private int
depth

The number of intermediate operations between this pipeline object and the stream source if sequential, or the previous stateful if parallel.

private boolean
linkedOrConsumed

True if this pipeline has been linked or consumed

private static final String
private static final String
private AbstractPipeline<E_IN, E_OUT, S extends BaseStream<E_OUT, S>>
nextStage

The next stage in the pipeline, or null if this is the last stage.

private boolean
parallel

True if pipeline is parallel, otherwise the pipeline is sequential; only valid for the source stage.

protected final AbstractPipeline<E_IN, E_OUT, S extends BaseStream<E_OUT, S>>
previousStage

The "upstream" pipeline, or null if this is the source stage.

private Runnable
protected final int
sourceOrOpFlags

The operation flags for the intermediate operation represented by this pipeline object.

private Spliterator<?>
sourceSpliterator

The source spliterator.

private final AbstractPipeline<E_IN, E_OUT, S extends BaseStream<E_OUT, S>>
sourceStage

Backlink to the head of the pipeline chain (self if this is the source stage).

private Supplier<? extends Spliterator<?>>
sourceSupplier

The source supplier.

Constructor Summary

AccessConstructor and Description
pack-priv
AbstractPipeline(Supplier<? extends Spliterator<?>>
Supplier<Spliterator> describing the stream source
source
,
int
The source flags for the stream source, described in StreamOpFlag
sourceFlags
,
boolean
True if the pipeline is parallel
parallel
)

Constructor for the head of a stream pipeline.

pack-priv
AbstractPipeline(Spliterator<?>
Spliterator describing the stream source
source
,
int
the source flags for the stream source, described in StreamOpFlag
sourceFlags
,
boolean
true if the pipeline is parallel
parallel
)

Constructor for the head of a stream pipeline.

pack-priv
AbstractPipeline(AbstractPipeline<?, E_IN, ?>
the upstream pipeline stage
previousStage
,
int
the operation flags for the new stage, described in StreamOpFlag
opFlags
)

Constructor for appending an intermediate operation stage onto an existing pipeline.

protected
AbstractPipeline(AbstractPipeline<?, E_IN, ?>
the upstream pipeline stage of the upstream pipeline stage
previousPreviousStage
,
AbstractPipeline<?, E_IN, ?>
the upstream pipeline stage
previousStage
,
int
the operation flags for the new stage, described in StreamOpFlag
opFlags
)

Constructor for replacing an intermediate operation stage onto an existing pipeline.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements java.util.stream.BaseStream.close.

Closes this stream, causing all close handlers for this stream pipeline to be called.

pack-priv final <P_IN> void
copyInto(Sink<P_IN> wrappedSink, Spliterator<P_IN> spliterator)

Implements abstract java.util.stream.PipelineHelper.copyInto.

Pushes elements obtained from the Spliterator into the provided Sink.

pack-priv final <P_IN> boolean
copyIntoWithCancel(Sink<P_IN> wrappedSink, Spliterator<P_IN> spliterator)

Implements abstract java.util.stream.PipelineHelper.copyIntoWithCancel.

Pushes elements obtained from the Spliterator into the provided Sink, checking Sink#cancellationRequested() after each element, and stopping if cancellation is requested.

pack-priv final <
the type of result
R
>
R

Returns:

the result
evaluate
(TerminalOp<E_OUT, R>
the terminal operation to be applied to the pipeline.
terminalOp
)

Evaluate the pipeline with a terminal operation to produce a result.

pack-priv final <P_IN> Node<E_OUT>
evaluate(Spliterator<P_IN> spliterator, boolean flatten, IntFunction<E_OUT[]> generator)

Implements abstract java.util.stream.PipelineHelper.evaluate.

Collects all output elements resulting from applying the pipeline stages to the source Spliterator into a Node.

pack-priv final Node<E_OUT>

Returns:

a flat array-backed Node that holds the collected output elements
evaluateToArrayNode
(IntFunction<E_OUT[]>
the array generator to be used to create array instances
generator
)

Collect the elements output from the pipeline stage.

pack-priv abstract <P_IN> Node<E_OUT>

Returns:

a Node holding the output of the pipeline
evaluateToNode
(PipelineHelper<E_OUT>
the pipeline helper describing the pipeline stages
helper
,
Spliterator<P_IN>
the source spliterator
spliterator
,
boolean
true if the returned node should be flattened
flattenTree
,
IntFunction<E_OUT[]>
the array generator
generator
)

Collect elements output from a pipeline into a Node that holds elements of this shape.

pack-priv long

Returns:

the output size of this stage
exactOutputSize
(long
the exact size reported by the previous stage
previousSize
)

Returns the exact output size of the pipeline given the exact size reported by the previous stage.

pack-priv final <P_IN> long
exactOutputSizeIfKnown(Spliterator<P_IN> spliterator)

Implements abstract java.util.stream.PipelineHelper.exactOutputSizeIfKnown.

Returns the exact output size of the portion of the output resulting from applying the pipeline stages described by this PipelineHelper to the portion of the input described by the provided Spliterator, if known.

pack-priv abstract boolean

Returns:

true if the cancellation was requested
forEachWithCancel
(Spliterator<E_OUT>
the spliterator to pull elements from
spliterator
,
Sink<E_OUT>
the sink to push elements to
sink
)

Traverse the elements of a spliterator compatible with this stream shape, pushing those elements into a sink.

pack-priv abstract StreamShape

Returns:

the output shape
getOutputShape
()

Get the output shape of the pipeline.

pack-priv final StreamShape
getSourceShape()

Implements abstract java.util.stream.PipelineHelper.getSourceShape.

Gets the stream shape for the source of the pipeline segment.

pack-priv final int
getStreamAndOpFlags()

Implements abstract java.util.stream.PipelineHelper.getStreamAndOpFlags.

Gets the combined stream and operation flags for the output of the described pipeline.

pack-priv final int

Returns:

the composition of stream flags of the stream source and all intermediate operations
getStreamFlags
()

Returns the composition of stream flags of the stream source and all intermediate operations.

protected final boolean

Returns:

true if any stage in this segment is stateful, false if not.
hasAnyStateful
()

Returns whether any of the stages of the current segment is stateful or not.

pack-priv final boolean
public final boolean
isParallel()

Implements java.util.stream.BaseStream.isParallel.

Returns whether this stream, if a terminal operation were to be executed, would execute in parallel.

protected final boolean

Returns:

true if any stage in this pipeline is short-circuiting, false if not.
isShortCircuitingPipeline
()

Returns whether any of the stages in the (entire) pipeline is short-circuiting or not.

pack-priv abstract Spliterator<E_OUT>
lazySpliterator(Supplier<? extends Spliterator<E_OUT>>
the supplier of a spliterator
supplier
)

Create a lazy spliterator that wraps and obtains the supplied the spliterator when a method is invoked on the lazy spliterator.

protected void
linkOrConsume()

Checks that the current stage has not been already linked or consumed, and then sets this stage as being linked or consumed.

pack-priv abstract Node.Builder<E_OUT>

Returns:

a node builder
makeNodeBuilder
(long
if >=0, then a node builder will be created that has a fixed capacity of at most sizeIfKnown elements. If < 0, then the node builder has an unfixed capacity. A fixed capacity node builder will throw exceptions if an element is added after builder has reached capacity, or is built before the builder has reached capacity.
exactSizeIfKnown
,
IntFunction<E_OUT[]>
the array generator to be used to create instances of a T[] array. For implementations supporting primitive nodes, this parameter may be ignored.
generator
)

Implements abstract java.util.stream.PipelineHelper.makeNodeBuilder.

Make a node builder compatible with this stream shape.

public S
onClose(Runnable closeHandler)

Implements java.util.stream.BaseStream.onClose.

Returns an equivalent stream with an additional close handler.

pack-priv <P_IN> Node<E_OUT>

Returns:

a Node describing the result of the evaluation
opEvaluateParallel
(PipelineHelper<E_OUT>
the pipeline helper describing the pipeline stages
helper
,
Spliterator<P_IN>
the source Spliterator
spliterator
,
IntFunction<E_OUT[]>
the array generator
generator
)

Performs a parallel evaluation of the operation using the specified PipelineHelper which describes the upstream intermediate operations.

pack-priv <P_IN> Spliterator<E_OUT>

Returns:

a Spliterator describing the result of the evaluation
opEvaluateParallelLazy
(PipelineHelper<E_OUT>
the pipeline helper
helper
,
Spliterator<P_IN>
the source Spliterator
spliterator
)

Returns a Spliterator describing a parallel evaluation of the operation, using the specified PipelineHelper which describes the upstream intermediate operations.

pack-priv abstract boolean

Returns:

true if this operation is stateful
opIsStateful
()

Returns whether this operation is stateful or not.

pack-priv abstract Sink<E_IN>

Returns:

a sink which accepts elements, perform the operation upon each element, and passes the results (if any) to the provided Sink.
opWrapSink
(int
The combined stream and operation flags up to, but not including, this operation
flags
,
Sink<E_OUT>
sink to which elements should be sent after processing
sink
)

Accepts a Sink which will receive the results of this operation, and return a Sink which accepts elements of the input type of this operation and which performs the operation, passing the results to the provided Sink.

public final S
parallel()

Implements java.util.stream.BaseStream.parallel.

Returns an equivalent stream that is parallel.

public final S
sequential()

Implements java.util.stream.BaseStream.sequential.

Returns an equivalent stream that is sequential.

protected Spliterator<?>
sourceSpliterator(int terminalFlags)

Get the source spliterator for this pipeline stage.

pack-priv final Spliterator<E_OUT>

Returns:

the source stage spliterator
sourceStageSpliterator
()

Gets the source stage spliterator if this pipeline stage is the source stage.

public Spliterator<E_OUT>
spliterator()

Implements java.util.stream.BaseStream.spliterator.

Returns a spliterator for the elements of this stream.

pack-priv abstract <P_IN> Spliterator<E_OUT>

Returns:

a wrapping spliterator compatible with this shape
wrap
(PipelineHelper<E_OUT>
the pipeline helper describing the pipeline stages
ph
,
Supplier<Spliterator<P_IN>>
the supplier of a spliterator
supplier
,
boolean isParallel)

Create a spliterator that wraps a source spliterator, compatible with this stream shape, and operations associated with a PipelineHelper.

pack-priv final <P_IN, S extends Sink<E_OUT>> S
wrapAndCopyInto(S sink, Spliterator<P_IN> spliterator)

Implements abstract java.util.stream.PipelineHelper.wrapAndCopyInto.

Applies the pipeline stages described by this PipelineHelper to the provided Spliterator and send the results to the provided Sink.

pack-priv final <P_IN> Sink<P_IN>
wrapSink(Sink<E_OUT> sink)

Implements abstract java.util.stream.PipelineHelper.wrapSink.

Takes a Sink that accepts elements of the output type of the PipelineHelper, and wrap it with a Sink that accepts elements of the input type and implements all the intermediate operations described by this PipelineHelper, delivering the result into the provided Sink.

pack-priv final <P_IN> Spliterator<E_OUT>

Field Detail

combinedFlagsback to summary
private int combinedFlags

The combined source and operation flags for the source and all operations up to and including the operation represented by this pipeline object. Valid at the point of pipeline preparation for evaluation.

depthback to summary
private int depth

The number of intermediate operations between this pipeline object and the stream source if sequential, or the previous stateful if parallel. Valid at the point of pipeline preparation for evaluation.

linkedOrConsumedback to summary
private boolean linkedOrConsumed

True if this pipeline has been linked or consumed

MSG_CONSUMEDback to summary
private static final String MSG_CONSUMED
MSG_STREAM_LINKEDback to summary
private static final String MSG_STREAM_LINKED
nextStageback to summary
private AbstractPipeline<E_IN, E_OUT, S extends BaseStream<E_OUT, S>> nextStage

The next stage in the pipeline, or null if this is the last stage. Effectively final at the point of linking to the next pipeline.

Annotations
@SuppressWarnings:rawtypes
parallelback to summary
private boolean parallel

True if pipeline is parallel, otherwise the pipeline is sequential; only valid for the source stage.

previousStageback to summary
protected final AbstractPipeline<E_IN, E_OUT, S extends BaseStream<E_OUT, S>> previousStage

The "upstream" pipeline, or null if this is the source stage.

Annotations
@SuppressWarnings:rawtypes
sourceCloseActionback to summary
private Runnable sourceCloseAction
sourceOrOpFlagsback to summary
protected final int sourceOrOpFlags

The operation flags for the intermediate operation represented by this pipeline object.

sourceSpliteratorback to summary
private Spliterator<?> sourceSpliterator

The source spliterator. Only valid for the head pipeline. Before the pipeline is consumed if non-null then sourceSupplier must be null. After the pipeline is consumed if non-null then is set to null.

sourceStageback to summary
private final AbstractPipeline<E_IN, E_OUT, S extends BaseStream<E_OUT, S>> sourceStage

Backlink to the head of the pipeline chain (self if this is the source stage).

Annotations
@SuppressWarnings:rawtypes
sourceSupplierback to summary
private Supplier<? extends Spliterator<?>> sourceSupplier

The source supplier. Only valid for the head pipeline. Before the pipeline is consumed if non-null then sourceSpliterator must be null. After the pipeline is consumed if non-null then is set to null.

Constructor Detail

AbstractPipelineback to summary
pack-priv AbstractPipeline(Supplier<? extends Spliterator<?>> source, int sourceFlags, boolean parallel)

Constructor for the head of a stream pipeline.

Parameters
source:Supplier<? extends Spliterator<?>>

Supplier<Spliterator> describing the stream source

sourceFlags:int

The source flags for the stream source, described in StreamOpFlag

parallel:boolean

True if the pipeline is parallel

AbstractPipelineback to summary
pack-priv AbstractPipeline(Spliterator<?> source, int sourceFlags, boolean parallel)

Constructor for the head of a stream pipeline.

Parameters
source:Spliterator<?>

Spliterator describing the stream source

sourceFlags:int

the source flags for the stream source, described in StreamOpFlag

parallel:boolean

true if the pipeline is parallel

AbstractPipelineback to summary
pack-priv AbstractPipeline(AbstractPipeline<?, E_IN, ?> previousStage, int opFlags)

Constructor for appending an intermediate operation stage onto an existing pipeline. The previous stage must be unlinked and unconsumed.

Parameters
previousStage:AbstractPipeline<?, E_IN, ?>

the upstream pipeline stage

opFlags:int

the operation flags for the new stage, described in StreamOpFlag

Exceptions
IllegalStateException:
if previousStage is already linked or consumed
AbstractPipelineback to summary
protected AbstractPipeline(AbstractPipeline<?, E_IN, ?> previousPreviousStage, AbstractPipeline<?, E_IN, ?> previousStage, int opFlags)

Constructor for replacing an intermediate operation stage onto an existing pipeline.

Parameters
previousPreviousStage:AbstractPipeline<?, E_IN, ?>

the upstream pipeline stage of the upstream pipeline stage

previousStage:AbstractPipeline<?, E_IN, ?>

the upstream pipeline stage

opFlags:int

the operation flags for the new stage, described in StreamOpFlag

Exceptions
IllegalStateException:
if previousStage is already linked or consumed

Method Detail

closeback to summary
public void close()

Implements java.util.stream.BaseStream.close.

Doc from java.util.stream.BaseStream.close.

Closes this stream, causing all close handlers for this stream pipeline to be called.

Annotations
@Override
copyIntoback to summary
pack-priv final <P_IN> void copyInto(Sink<P_IN> wrappedSink, Spliterator<P_IN> spliterator)

Implements abstract java.util.stream.PipelineHelper.copyInto.

Doc from java.util.stream.PipelineHelper.copyInto.

Pushes elements obtained from the Spliterator into the provided Sink. If the stream pipeline is known to have short-circuiting stages in it (see StreamOpFlag#SHORT_CIRCUIT), the Sink#cancellationRequested() is checked after each element, stopping if cancellation is requested.

Annotations
@Override
copyIntoWithCancelback to summary
pack-priv final <P_IN> boolean copyIntoWithCancel(Sink<P_IN> wrappedSink, Spliterator<P_IN> spliterator)

Implements abstract java.util.stream.PipelineHelper.copyIntoWithCancel.

Doc from java.util.stream.PipelineHelper.copyIntoWithCancel.

Pushes elements obtained from the Spliterator into the provided Sink, checking Sink#cancellationRequested() after each element, and stopping if cancellation is requested.

Annotations
@Override
@SuppressWarnings:unchecked
evaluateback to summary
pack-priv final <R> R evaluate(TerminalOp<E_OUT, R> terminalOp)

Evaluate the pipeline with a terminal operation to produce a result.

Parameters
<R>
the type of result
terminalOp:TerminalOp<E_OUT, R>

the terminal operation to be applied to the pipeline.

Returns:R

the result

evaluateback to summary
pack-priv final <P_IN> Node<E_OUT> evaluate(Spliterator<P_IN> spliterator, boolean flatten, IntFunction<E_OUT[]> generator)

Implements abstract java.util.stream.PipelineHelper.evaluate.

Doc from java.util.stream.PipelineHelper.evaluate.

Collects all output elements resulting from applying the pipeline stages to the source Spliterator into a Node.

Annotations
@Override
evaluateToArrayNodeback to summary
pack-priv final Node<E_OUT> evaluateToArrayNode(IntFunction<E_OUT[]> generator)

Collect the elements output from the pipeline stage.

Parameters
generator:IntFunction<E_OUT[]>

the array generator to be used to create array instances

Returns:Node<E_OUT>

a flat array-backed Node that holds the collected output elements

Annotations
@SuppressWarnings:unchecked
evaluateToNodeback to summary
pack-priv abstract <P_IN> Node<E_OUT> evaluateToNode(PipelineHelper<E_OUT> helper, Spliterator<P_IN> spliterator, boolean flattenTree, IntFunction<E_OUT[]> generator)

Collect elements output from a pipeline into a Node that holds elements of this shape.

Parameters
helper:PipelineHelper<E_OUT>

the pipeline helper describing the pipeline stages

spliterator:Spliterator<P_IN>

the source spliterator

flattenTree:boolean

true if the returned node should be flattened

generator:IntFunction<E_OUT[]>

the array generator

Returns:Node<E_OUT>

a Node holding the output of the pipeline

exactOutputSizeback to summary
pack-priv long exactOutputSize(long previousSize)

Returns the exact output size of the pipeline given the exact size reported by the previous stage.

Parameters
previousSize:long

the exact size reported by the previous stage

Returns:long

the output size of this stage

exactOutputSizeIfKnownback to summary
pack-priv final <P_IN> long exactOutputSizeIfKnown(Spliterator<P_IN> spliterator)

Implements abstract java.util.stream.PipelineHelper.exactOutputSizeIfKnown.

Doc from java.util.stream.PipelineHelper.exactOutputSizeIfKnown.

Returns the exact output size of the portion of the output resulting from applying the pipeline stages described by this PipelineHelper to the portion of the input described by the provided Spliterator, if known. If not known or known infinite, will return -1.

Annotations
@Override
forEachWithCancelback to summary
pack-priv abstract boolean forEachWithCancel(Spliterator<E_OUT> spliterator, Sink<E_OUT> sink)

Traverse the elements of a spliterator compatible with this stream shape, pushing those elements into a sink. If the sink requests cancellation, no further elements will be pulled or pushed.

Parameters
spliterator:Spliterator<E_OUT>

the spliterator to pull elements from

sink:Sink<E_OUT>

the sink to push elements to

Returns:boolean

true if the cancellation was requested

getOutputShapeback to summary
pack-priv abstract StreamShape getOutputShape()

Get the output shape of the pipeline. If the pipeline is the head, then its output shape corresponds to the shape of the source. Otherwise, its output shape corresponds to the output shape of the associated operation.

Returns:StreamShape

the output shape

getSourceShapeback to summary
pack-priv final StreamShape getSourceShape()

Implements abstract java.util.stream.PipelineHelper.getSourceShape.

Doc from java.util.stream.PipelineHelper.getSourceShape.

Gets the stream shape for the source of the pipeline segment.

Annotations
@Override
getStreamAndOpFlagsback to summary
pack-priv final int getStreamAndOpFlags()

Implements abstract java.util.stream.PipelineHelper.getStreamAndOpFlags.

Doc from java.util.stream.PipelineHelper.getStreamAndOpFlags.

Gets the combined stream and operation flags for the output of the described pipeline. This will incorporate stream flags from the stream source, all the intermediate operations and the terminal operation.

Annotations
@Override
getStreamFlagsback to summary
pack-priv final int getStreamFlags()

Returns the composition of stream flags of the stream source and all intermediate operations.

Returns:int

the composition of stream flags of the stream source and all intermediate operations

See Also
StreamOpFlag
hasAnyStatefulback to summary
protected final boolean hasAnyStateful()

Returns whether any of the stages of the current segment is stateful or not.

Returns:boolean

true if any stage in this segment is stateful, false if not.

isOrderedback to summary
pack-priv final boolean isOrdered()
isParallelback to summary
public final boolean isParallel()

Implements java.util.stream.BaseStream.isParallel.

Doc from java.util.stream.BaseStream.isParallel.

Returns whether this stream, if a terminal operation were to be executed, would execute in parallel. Calling this method after invoking an terminal stream operation method may yield unpredictable results.

Annotations
@Override
isShortCircuitingPipelineback to summary
protected final boolean isShortCircuitingPipeline()

Returns whether any of the stages in the (entire) pipeline is short-circuiting or not.

Returns:boolean

true if any stage in this pipeline is short-circuiting, false if not.

lazySpliteratorback to summary
pack-priv abstract Spliterator<E_OUT> lazySpliterator(Supplier<? extends Spliterator<E_OUT>> supplier)

Create a lazy spliterator that wraps and obtains the supplied the spliterator when a method is invoked on the lazy spliterator.

Parameters
supplier:Supplier<? extends Spliterator<E_OUT>>

the supplier of a spliterator

linkOrConsumeback to summary
protected void linkOrConsume()

Checks that the current stage has not been already linked or consumed, and then sets this stage as being linked or consumed.

makeNodeBuilderback to summary
pack-priv abstract Node.Builder<E_OUT> makeNodeBuilder(long exactSizeIfKnown, IntFunction<E_OUT[]> generator)

Implements abstract java.util.stream.PipelineHelper.makeNodeBuilder.

Make a node builder compatible with this stream shape.

Parameters
exactSizeIfKnown:long

if >=0, then a node builder will be created that has a fixed capacity of at most sizeIfKnown elements. If < 0, then the node builder has an unfixed capacity. A fixed capacity node builder will throw exceptions if an element is added after builder has reached capacity, or is built before the builder has reached capacity.

generator:IntFunction<E_OUT[]>

the array generator to be used to create instances of a T[] array. For implementations supporting primitive nodes, this parameter may be ignored.

Returns:Node.Builder<E_OUT>

a node builder

Annotations
@Override
onCloseback to summary
public S onClose(Runnable closeHandler)

Implements java.util.stream.BaseStream.onClose.

Doc from java.util.stream.BaseStream.onClose.

Returns an equivalent stream with an additional close handler. Close handlers are run when the 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.

Annotations
@Override
@SuppressWarnings:unchecked
opEvaluateParallelback to summary
pack-priv <P_IN> Node<E_OUT> opEvaluateParallel(PipelineHelper<E_OUT> helper, Spliterator<P_IN> spliterator, IntFunction<E_OUT[]> generator)

Performs a parallel evaluation of the operation using the specified PipelineHelper which describes the upstream intermediate operations. Only called on stateful operations. If opIsStateful() returns true then implementations must override the default implementation.

Implementation Specification

The default implementation always throw UnsupportedOperationException.

Parameters
helper:PipelineHelper<E_OUT>

the pipeline helper describing the pipeline stages

spliterator:Spliterator<P_IN>

the source Spliterator

generator:IntFunction<E_OUT[]>

the array generator

Returns:Node<E_OUT>

a Node describing the result of the evaluation

opEvaluateParallelLazyback to summary
pack-priv <P_IN> Spliterator<E_OUT> opEvaluateParallelLazy(PipelineHelper<E_OUT> helper, Spliterator<P_IN> spliterator)

Returns a Spliterator describing a parallel evaluation of the operation, using the specified PipelineHelper which describes the upstream intermediate operations. Only called on stateful operations. It is not necessary (though acceptable) to do a full computation of the result here; it is preferable, if possible, to describe the result via a lazily evaluated spliterator.

Implementation Specification

The default implementation behaves as if:

return evaluateParallel(helper, i -> (E_OUT[]) new
Object[i]).spliterator();
and is suitable for implementations that cannot do better than a full synchronous evaluation.
Parameters
helper:PipelineHelper<E_OUT>

the pipeline helper

spliterator:Spliterator<P_IN>

the source Spliterator

Returns:Spliterator<E_OUT>

a Spliterator describing the result of the evaluation

opIsStatefulback to summary
pack-priv abstract boolean opIsStateful()

Returns whether this operation is stateful or not. If it is stateful, then the method opEvaluateParallel(PipelineHelper, java.util.Spliterator, java.util.function.IntFunction) must be overridden.

Returns:boolean

true if this operation is stateful

opWrapSinkback to summary
pack-priv abstract Sink<E_IN> opWrapSink(int flags, Sink<E_OUT> sink)

Accepts a Sink which will receive the results of this operation, and return a Sink which accepts elements of the input type of this operation and which performs the operation, passing the results to the provided Sink.

API Note

The implementation may use the flags parameter to optimize the sink wrapping. For example, if the input is already DISTINCT, the implementation for the Stream#distinct() method could just return the sink it was passed.

Parameters
flags:int

The combined stream and operation flags up to, but not including, this operation

sink:Sink<E_OUT>

sink to which elements should be sent after processing

Returns:Sink<E_IN>

a sink which accepts elements, perform the operation upon each element, and passes the results (if any) to the provided Sink.

parallelback to summary
public final S parallel()

Implements java.util.stream.BaseStream.parallel.

Doc from java.util.stream.BaseStream.parallel.

Returns an equivalent stream that is parallel. May return itself, either because the stream was already parallel, or because the underlying stream state was modified to be parallel.

This is an intermediate operation.

Annotations
@Override
@SuppressWarnings:unchecked
sequentialback to summary
public final S sequential()

Implements java.util.stream.BaseStream.sequential.

Doc from java.util.stream.BaseStream.sequential.

Returns an equivalent stream that is sequential. May return itself, either because the stream was already sequential, or because the underlying stream state was modified to be sequential.

This is an intermediate operation.

Annotations
@Override
@SuppressWarnings:unchecked
sourceSpliteratorback to summary
protected Spliterator<?> sourceSpliterator(int terminalFlags)

Get the source spliterator for this pipeline stage. For a sequential or stateless parallel pipeline, this is the source spliterator. For a stateful parallel pipeline, this is a spliterator describing the results of all computations up to and including the most recent stateful operation.

Annotations
@SuppressWarnings:unchecked
sourceStageSpliteratorback to summary
pack-priv final Spliterator<E_OUT> sourceStageSpliterator()

Gets the source stage spliterator if this pipeline stage is the source stage. The pipeline is consumed after this method is called and returns successfully.

Returns:Spliterator<E_OUT>

the source stage spliterator

Exceptions
IllegalStateException:
if this pipeline stage is not the source stage.
spliteratorback to summary
public Spliterator<E_OUT> spliterator()

Implements java.util.stream.BaseStream.spliterator.

Doc from java.util.stream.BaseStream.spliterator.

Returns a spliterator for the elements of this stream.

This is a terminal operation.

Annotations
@Override
@SuppressWarnings:unchecked
wrapback to summary
pack-priv abstract <P_IN> Spliterator<E_OUT> wrap(PipelineHelper<E_OUT> ph, Supplier<Spliterator<P_IN>> supplier, boolean isParallel)

Create a spliterator that wraps a source spliterator, compatible with this stream shape, and operations associated with a PipelineHelper.

Parameters
ph:PipelineHelper<E_OUT>

the pipeline helper describing the pipeline stages

supplier:Supplier<Spliterator<P_IN>>

the supplier of a spliterator

Returns:Spliterator<E_OUT>

a wrapping spliterator compatible with this shape

wrapAndCopyIntoback to summary
pack-priv final <P_IN, S extends Sink<E_OUT>> S wrapAndCopyInto(S sink, Spliterator<P_IN> spliterator)

Implements abstract java.util.stream.PipelineHelper.wrapAndCopyInto.

Doc from java.util.stream.PipelineHelper.wrapAndCopyInto.

Applies the pipeline stages described by this PipelineHelper to the provided Spliterator and send the results to the provided Sink.

Annotations
@Override
wrapSinkback to summary
pack-priv final <P_IN> Sink<P_IN> wrapSink(Sink<E_OUT> sink)

Implements abstract java.util.stream.PipelineHelper.wrapSink.

Doc from java.util.stream.PipelineHelper.wrapSink.

Takes a Sink that accepts elements of the output type of the PipelineHelper, and wrap it with a Sink that accepts elements of the input type and implements all the intermediate operations described by this PipelineHelper, delivering the result into the provided Sink.

Annotations
@Override
@SuppressWarnings:unchecked
wrapSpliteratorback to summary
pack-priv final <P_IN> Spliterator<E_OUT> wrapSpliterator(Spliterator<P_IN> sourceSpliterator)

Implements abstract java.util.stream.PipelineHelper.wrapSpliterator.

Annotations
@Override
@SuppressWarnings:unchecked