Top Description Inners Constructors Methods
java.util.stream

pack-priv final Class FindOps

extends Object
Class Inheritance
Imports
java.util.Optional, .OptionalDouble, .OptionalInt, .OptionalLong, .Spliterator, java.util.concurrent.CountedCompleter, java.util.function.Predicate, .Supplier

Factory for instances of a short-circuiting TerminalOp that searches for an element in a stream pipeline, and terminates when it finds one. Supported variants include find-first (find the first element in the encounter order) and find-any (find any element, may not be the first in encounter order.)
Since
1.8

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
FindOps.FindOp<
the output type of the stream pipeline
T
,
the result type of the find operation, typically an optional type
O
>

A short-circuiting TerminalOp that searches for an element in a stream pipeline, and terminates when it finds one.

private abstract static class
FindOps.FindSink<
The type of input element
T
,
The result type, typically an optional type
O
>

Implementation of TerminalSink that implements the find functionality, requesting cancellation when something has been found

private static class
FindOps.FindTask<
Input element type to the stream pipeline
P_IN
,
Output element type from the stream pipeline
P_OUT
,
Result type from the find operation
O
>

ForkJoinTask implementing parallel short-circuiting search

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static TerminalOp<Double, OptionalDouble>

Returns:

a TerminalOp implementing the find operation
makeDouble
(boolean
whether the TerminalOp must produce the first element in the encounter order
mustFindFirst
)

Constructs a FindOp for streams of doubles.

public static TerminalOp<Integer, OptionalInt>

Returns:

a TerminalOp implementing the find operation
makeInt
(boolean
whether the TerminalOp must produce the first element in the encounter order
mustFindFirst
)

Constructs a TerminalOp for streams of ints.

public static TerminalOp<Long, OptionalLong>

Returns:

a TerminalOp implementing the find operation
makeLong
(boolean
whether the TerminalOp must produce the first element in the encounter order
mustFindFirst
)

Constructs a TerminalOp for streams of longs.

public static <
the type of elements of the stream
T
>
TerminalOp<T, Optional<T>>

Returns:

a TerminalOp implementing the find operation
makeRef
(boolean
whether the TerminalOp must produce the first element in the encounter order
mustFindFirst
)

Constructs a TerminalOp for streams of objects.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

FindOpsback to summary
private FindOps()

Method Detail

makeDoubleback to summary
public static TerminalOp<Double, OptionalDouble> makeDouble(boolean mustFindFirst)

Constructs a FindOp for streams of doubles.

Parameters
mustFindFirst:boolean

whether the TerminalOp must produce the first element in the encounter order

Returns:TerminalOp<Double, OptionalDouble>

a TerminalOp implementing the find operation

makeIntback to summary
public static TerminalOp<Integer, OptionalInt> makeInt(boolean mustFindFirst)

Constructs a TerminalOp for streams of ints.

Parameters
mustFindFirst:boolean

whether the TerminalOp must produce the first element in the encounter order

Returns:TerminalOp<Integer, OptionalInt>

a TerminalOp implementing the find operation

makeLongback to summary
public static TerminalOp<Long, OptionalLong> makeLong(boolean mustFindFirst)

Constructs a TerminalOp for streams of longs.

Parameters
mustFindFirst:boolean

whether the TerminalOp must produce the first element in the encounter order

Returns:TerminalOp<Long, OptionalLong>

a TerminalOp implementing the find operation

makeRefback to summary
public static <T> TerminalOp<T, Optional<T>> makeRef(boolean mustFindFirst)

Constructs a TerminalOp for streams of objects.

Parameters
<T>
the type of elements of the stream
mustFindFirst:boolean

whether the TerminalOp must produce the first element in the encounter order

Returns:TerminalOp<T, Optional<T>>

a TerminalOp implementing the find operation

Annotations
@SuppressWarnings:unchecked
java.util.stream back to summary

private final Class FindOps.FindOp<T, O>

extends Object
implements TerminalOp<T, O>
Class Inheritance
All Implemented Interfaces
java.util.stream.TerminalOp
Type Parameters
<T>
the output type of the stream pipeline
<O>
the result type of the find operation, typically an optional type

A short-circuiting TerminalOp that searches for an element in a stream pipeline, and terminates when it finds one. Implements both find-first (find the first element in the encounter order) and find-any (find any element, may not be the first in encounter order.)

Field Summary

Modifier and TypeField and Description
pack-priv final O
pack-priv final int
pack-priv final Predicate<O>
private final StreamShape
pack-priv final Supplier<TerminalSink<T, O>>

Constructor Summary

AccessConstructor and Description
pack-priv
FindOp(boolean
if true, must find the first element in encounter order, otherwise can find any element
mustFindFirst
,
StreamShape
stream shape of elements to search
shape
,
O
result value corresponding to "found nothing"
emptyValue
,
Predicate<O>
Predicate on result value corresponding to "found something"
presentPredicate
,
Supplier<TerminalSink<T, O>>
supplier for a TerminalSink implementing the matching functionality
sinkSupplier
)

Constructs a FindOp.

Method Summary

Modifier and TypeMethod and Description
public <P_IN> O
evaluateParallel(PipelineHelper<T>
the pipeline helper
helper
,
Spliterator<P_IN>
the source spliterator
spliterator
)

Overrides default java.util.stream.TerminalOp.evaluateParallel.

Performs a parallel evaluation of the operation using the specified PipelineHelper, which describes the upstream intermediate operations.
public <S> O
evaluateSequential(PipelineHelper<T>
the pipeline helper
helper
,
Spliterator<S>
the source spliterator
spliterator
)

Implements java.util.stream.TerminalOp.evaluateSequential.

Performs a sequential evaluation of the operation using the specified PipelineHelper, which describes the upstream intermediate operations.
public int
getOpFlags()

Overrides default java.util.stream.TerminalOp.getOpFlags.

Gets the stream flags of the operation.
public StreamShape
inputShape()

Overrides default java.util.stream.TerminalOp.inputShape.

Gets the shape of the input type of this operation.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

emptyValueback to summary
pack-priv final O emptyValue
opFlagsback to summary
pack-priv final int opFlags
presentPredicateback to summary
pack-priv final Predicate<O> presentPredicate
shapeback to summary
private final StreamShape shape
sinkSupplierback to summary
pack-priv final Supplier<TerminalSink<T, O>> sinkSupplier

Constructor Detail

FindOpback to summary
pack-priv FindOp(boolean mustFindFirst, StreamShape shape, O emptyValue, Predicate<O> presentPredicate, Supplier<TerminalSink<T, O>> sinkSupplier)

Constructs a FindOp.

Parameters
mustFindFirst:boolean

if true, must find the first element in encounter order, otherwise can find any element

shape:StreamShape

stream shape of elements to search

emptyValue:O

result value corresponding to "found nothing"

presentPredicate:Predicate<O>

Predicate on result value corresponding to "found something"

sinkSupplier:Supplier<TerminalSink<T, O>>

supplier for a TerminalSink implementing the matching functionality

Method Detail

evaluateParallelback to summary
public <P_IN> O evaluateParallel(PipelineHelper<T> helper, Spliterator<P_IN> spliterator)

Overrides default java.util.stream.TerminalOp.evaluateParallel.

Doc from java.util.stream.TerminalOp.evaluateParallel.

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

Parameters
helper:PipelineHelper<T>

the pipeline helper

spliterator:Spliterator<P_IN>

the source spliterator

Returns:O

the result of the evaluation

Annotations
@Override
evaluateSequentialback to summary
public <S> O evaluateSequential(PipelineHelper<T> helper, Spliterator<S> spliterator)

Implements java.util.stream.TerminalOp.evaluateSequential.

Doc from java.util.stream.TerminalOp.evaluateSequential.

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

Parameters
helper:PipelineHelper<T>

the pipeline helper

spliterator:Spliterator<S>

the source spliterator

Returns:O

the result of the evaluation

Annotations
@Override
getOpFlagsback to summary
public int getOpFlags()

Overrides default java.util.stream.TerminalOp.getOpFlags.

Doc from java.util.stream.TerminalOp.getOpFlags.

Gets the stream flags of the operation. Terminal operations may set a limited subset of the stream flags defined in StreamOpFlag, and these flags are combined with the previously combined stream and intermediate operation flags for the pipeline.

Returns:int

the stream flags for this operation

Annotations
@Override
inputShapeback to summary
public StreamShape inputShape()

Overrides default java.util.stream.TerminalOp.inputShape.

Doc from java.util.stream.TerminalOp.inputShape.

Gets the shape of the input type of this operation.

Returns:StreamShape

StreamShape of the input type of this operation

Annotations
@Override
java.util.stream back to summary

private abstract Class FindOps.FindSink<T, O>

extends Object
implements TerminalSink<T, O>
Class Inheritance
All Implemented Interfaces
java.util.stream.TerminalSink, java.util.function.Supplier, java.util.stream.Sink, java.util.function.Consumer
Known Direct Subclasses
java.util.stream.FindOps.FindSink.OfRef, java.util.stream.FindOps.FindSink.OfInt, java.util.stream.FindOps.FindSink.OfLong, java.util.stream.FindOps.FindSink.OfDouble
Type Parameters
<T>
The type of input element
<O>
The result type, typically an optional type

Implementation of TerminalSink that implements the find functionality, requesting cancellation when something has been found

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
FindOps.FindSink.OfDouble

Specialization of FindSink for double streams

pack-priv static class
FindOps.FindSink.OfInt

Specialization of FindSink for int streams

pack-priv static class
FindOps.FindSink.OfLong

Specialization of FindSink for long streams

pack-priv static class
FindOps.FindSink.OfRef<T>

Specialization of FindSink for reference streams

Field Summary

Modifier and TypeField and Description
pack-priv boolean
pack-priv T

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
accept(T
the input argument
value
)

Implements java.util.function.Consumer.accept.

Performs this operation on the given argument.
public boolean
cancellationRequested()

Overrides default java.util.stream.Sink.cancellationRequested.

Indicates that this Sink does not wish to receive any more data.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

hasValueback to summary
pack-priv boolean hasValue
valueback to summary
pack-priv T value

Constructor Detail

FindSinkback to summary
pack-priv FindSink()

Method Detail

acceptback to summary
public void accept(T value)

Implements java.util.function.Consumer.accept.

Doc from java.util.function.Consumer.accept.

Performs this operation on the given argument.

Parameters
value:T

the input argument

Annotations
@Override
cancellationRequestedback to summary
public boolean cancellationRequested()

Overrides default java.util.stream.Sink.cancellationRequested.

Doc from java.util.stream.Sink.cancellationRequested.

Indicates that this Sink does not wish to receive any more data.

Returns:boolean

true if cancellation is requested

Annotations
@Override
java.util.stream back to summary

pack-priv final Class FindOps.FindSink.OfDouble

extends FindOps.FindSink<Double, OptionalDouble>
implements OfDouble
Class Inheritance
All Implemented Interfaces
java.util.stream.Sink.OfDouble, java.util.function.DoubleConsumer, java.util.stream.Sink, java.util.function.Consumer

Specialization of FindSink for double streams

Field Summary

Modifier and TypeField and Description
pack-priv static final TerminalOp<Double, OptionalDouble>
pack-priv static final TerminalOp<Double, OptionalDouble>
Inherited from java.util.stream.FindOps.FindSink:
hasValuevalue

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
accept(double
the input argument
value
)

Overrides java.util.stream.FindOps.FindSink.accept.

Overrides default java.util.stream.Sink.accept.

Implements java.util.stream.Sink.OfDouble.accept.

Accepts a double value.
public OptionalDouble
get()

Implements java.util.function.Supplier.get.

Gets a result.
Inherited from java.util.stream.FindOps.FindSink:
cancellationRequested

Field Detail

OP_FIND_ANYback to summary
pack-priv static final TerminalOp<Double, OptionalDouble> OP_FIND_ANY
OP_FIND_FIRSTback to summary
pack-priv static final TerminalOp<Double, OptionalDouble> OP_FIND_FIRST

Constructor Detail

OfDoubleback to summary
pack-priv OfDouble()

Method Detail

acceptback to summary
public void accept(double value)

Overrides java.util.stream.FindOps.FindSink.accept.

Overrides default java.util.stream.Sink.accept.

Implements java.util.stream.Sink.OfDouble.accept.

Doc from java.util.stream.Sink.accept.

Accepts a double value.

Parameters
value:double

Doc from java.util.function.DoubleConsumer.accept.

the input argument

Annotations
@Override
getback to summary
public OptionalDouble get()

Implements java.util.function.Supplier.get.

Doc from java.util.function.Supplier.get.

Gets a result.

Returns:OptionalDouble

a result

Annotations
@Override
java.util.stream back to summary

pack-priv final Class FindOps.FindSink.OfInt

extends FindOps.FindSink<Integer, OptionalInt>
implements OfInt
Class Inheritance
All Implemented Interfaces
java.util.stream.Sink.OfInt, java.util.function.IntConsumer, java.util.stream.Sink, java.util.function.Consumer

Specialization of FindSink for int streams

Field Summary

Modifier and TypeField and Description
pack-priv static final TerminalOp<Integer, OptionalInt>
pack-priv static final TerminalOp<Integer, OptionalInt>
Inherited from java.util.stream.FindOps.FindSink:
hasValuevalue

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
accept(int
the input argument
value
)

Overrides java.util.stream.FindOps.FindSink.accept.

Overrides default java.util.stream.Sink.accept.

Implements java.util.stream.Sink.OfInt.accept.

Accepts an int value.
public OptionalInt
get()

Implements java.util.function.Supplier.get.

Gets a result.
Inherited from java.util.stream.FindOps.FindSink:
cancellationRequested

Field Detail

OP_FIND_ANYback to summary
pack-priv static final TerminalOp<Integer, OptionalInt> OP_FIND_ANY
OP_FIND_FIRSTback to summary
pack-priv static final TerminalOp<Integer, OptionalInt> OP_FIND_FIRST

Constructor Detail

OfIntback to summary
pack-priv OfInt()

Method Detail

acceptback to summary
public void accept(int value)

Overrides java.util.stream.FindOps.FindSink.accept.

Overrides default java.util.stream.Sink.accept.

Implements java.util.stream.Sink.OfInt.accept.

Doc from java.util.stream.Sink.accept.

Accepts an int value.

Parameters
value:int

Doc from java.util.function.IntConsumer.accept.

the input argument

Annotations
@Override
getback to summary
public OptionalInt get()

Implements java.util.function.Supplier.get.

Doc from java.util.function.Supplier.get.

Gets a result.

Returns:OptionalInt

a result

Annotations
@Override
java.util.stream back to summary

pack-priv final Class FindOps.FindSink.OfLong

extends FindOps.FindSink<Long, OptionalLong>
implements OfLong
Class Inheritance
All Implemented Interfaces
java.util.stream.Sink.OfLong, java.util.function.LongConsumer, java.util.stream.Sink, java.util.function.Consumer

Specialization of FindSink for long streams

Field Summary

Modifier and TypeField and Description
pack-priv static final TerminalOp<Long, OptionalLong>
pack-priv static final TerminalOp<Long, OptionalLong>
Inherited from java.util.stream.FindOps.FindSink:
hasValuevalue

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
accept(long
the input argument
value
)

Overrides java.util.stream.FindOps.FindSink.accept.

Overrides default java.util.stream.Sink.accept.

Implements java.util.stream.Sink.OfLong.accept.

Accepts a long value.
public OptionalLong
get()

Implements java.util.function.Supplier.get.

Gets a result.
Inherited from java.util.stream.FindOps.FindSink:
cancellationRequested

Field Detail

OP_FIND_ANYback to summary
pack-priv static final TerminalOp<Long, OptionalLong> OP_FIND_ANY
OP_FIND_FIRSTback to summary
pack-priv static final TerminalOp<Long, OptionalLong> OP_FIND_FIRST

Constructor Detail

OfLongback to summary
pack-priv OfLong()

Method Detail

acceptback to summary
public void accept(long value)

Overrides java.util.stream.FindOps.FindSink.accept.

Overrides default java.util.stream.Sink.accept.

Implements java.util.stream.Sink.OfLong.accept.

Doc from java.util.stream.Sink.accept.

Accepts a long value.

Parameters
value:long

Doc from java.util.function.LongConsumer.accept.

the input argument

Annotations
@Override
getback to summary
public OptionalLong get()

Implements java.util.function.Supplier.get.

Doc from java.util.function.Supplier.get.

Gets a result.

Returns:OptionalLong

a result

Annotations
@Override
java.util.stream back to summary

pack-priv final Class FindOps.FindSink.OfRef<T>

extends FindOps.FindSink<T, Optional<T>>
Class Inheritance

Specialization of FindSink for reference streams

Field Summary

Modifier and TypeField and Description
pack-priv static final TerminalOp<?, ?>
pack-priv static final TerminalOp<?, ?>
Inherited from java.util.stream.FindOps.FindSink:
hasValuevalue

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public Optional<T>
get()

Implements java.util.function.Supplier.get.

Gets a result.
Inherited from java.util.stream.FindOps.FindSink:
acceptcancellationRequested

Field Detail

OP_FIND_ANYback to summary
pack-priv static final TerminalOp<?, ?> OP_FIND_ANY
OP_FIND_FIRSTback to summary
pack-priv static final TerminalOp<?, ?> OP_FIND_FIRST

Constructor Detail

OfRefback to summary
pack-priv OfRef()

Method Detail

getback to summary
public Optional<T> get()

Implements java.util.function.Supplier.get.

Doc from java.util.function.Supplier.get.

Gets a result.

Returns:Optional<T>

a result

Annotations
@Override
java.util.stream back to summary

private final Class FindOps.FindTask<P_IN, P_OUT, O>

extends AbstractShortCircuitTask<P_IN, P_OUT, O, FindOps.FindTask<P_IN, P_OUT, O>>
Class Inheritance
Annotations
@SuppressWarnings:serial
Type Parameters
<P_IN>
Input element type to the stream pipeline
<P_OUT>
Output element type from the stream pipeline
<O>
Result type from the find operation

ForkJoinTask implementing parallel short-circuiting search

Field Summary

Modifier and TypeField and Description
private final boolean
private final FindOps.FindOp<P_OUT, O>
Inherited from java.util.stream.AbstractShortCircuitTask:
canceledsharedResult

Constructor Summary

AccessConstructor and Description
pack-priv
FindTask(FindOps.FindOp<P_OUT, O> op, boolean mustFindFirst, PipelineHelper<P_OUT> helper, Spliterator<P_IN> spliterator)

pack-priv
FindTask(FindOps.FindTask<P_IN, P_OUT, O> parent, Spliterator<P_IN> spliterator)

Method Summary

Modifier and TypeMethod and Description
protected O
doLeaf()

Implements abstract java.util.stream.AbstractTask.doLeaf.

Computes the result associated with a leaf node.
private void
foundResult(O answer)

protected O
getEmptyResult()

Implements abstract java.util.stream.AbstractShortCircuitTask.getEmptyResult.

Returns the value indicating the computation completed with no task finding a short-circuitable result.
protected FindOps.FindTask<P_IN, P_OUT, O>
makeChild(Spliterator<P_IN>
Spliterator describing the subtree rooted at this node, obtained by splitting the parent Spliterator
spliterator
)

Implements abstract java.util.stream.AbstractTask.makeChild.

Constructs a new node of type T whose parent is the receiver; must call the AbstractTask(T, Spliterator) constructor with the receiver and the provided Spliterator.
public void
onCompletion(CountedCompleter<?>
the task invoking this method (which may be this task itself)
caller
)

Overrides java.util.stream.AbstractTask.onCompletion.

Performs an action when method tryComplete is invoked and the pending count is zero, or when the unconditional method complete is invoked.
Inherited from java.util.stream.AbstractShortCircuitTask:
cancelcancelLaterNodescomputegetLocalResultgetRawResultsetLocalResultshortCircuittaskCanceled

Field Detail

mustFindFirstback to summary
private final boolean mustFindFirst
opback to summary
private final FindOps.FindOp<P_OUT, O> op

Constructor Detail

FindTaskback to summary
pack-priv FindTask(FindOps.FindOp<P_OUT, O> op, boolean mustFindFirst, PipelineHelper<P_OUT> helper, Spliterator<P_IN> spliterator)
FindTaskback to summary
pack-priv FindTask(FindOps.FindTask<P_IN, P_OUT, O> parent, Spliterator<P_IN> spliterator)

Method Detail

doLeafback to summary
protected O doLeaf()

Implements abstract java.util.stream.AbstractTask.doLeaf.

Doc from java.util.stream.AbstractTask.doLeaf.

Computes the result associated with a leaf node. Will be called by compute() and the result passed to setLocalResult()

Returns:O

the computed result of a leaf node

Annotations
@Override
foundResultback to summary
private void foundResult(O answer)
getEmptyResultback to summary
protected O getEmptyResult()

Implements abstract java.util.stream.AbstractShortCircuitTask.getEmptyResult.

Doc from java.util.stream.AbstractShortCircuitTask.getEmptyResult.

Returns the value indicating the computation completed with no task finding a short-circuitable result. For example, for a "find" operation, this might be null or an empty Optional.

Returns:O

the result to return when no task finds a result

Annotations
@Override
makeChildback to summary
protected FindOps.FindTask<P_IN, P_OUT, O> makeChild(Spliterator<P_IN> spliterator)

Implements abstract java.util.stream.AbstractTask.makeChild.

Doc from java.util.stream.AbstractTask.makeChild.

Constructs a new node of type T whose parent is the receiver; must call the AbstractTask(T, Spliterator) constructor with the receiver and the provided Spliterator.

Parameters
spliterator:Spliterator<P_IN>

Spliterator describing the subtree rooted at this node, obtained by splitting the parent Spliterator

Returns:FindOps.FindTask<P_IN, P_OUT, O>

newly constructed child node

Annotations
@Override
onCompletionback to summary
public void onCompletion(CountedCompleter<?> caller)

Overrides java.util.stream.AbstractTask.onCompletion.

Doc from java.util.stream.AbstractTask.onCompletion.

Performs an action when method tryComplete is invoked and the pending count is zero, or when the unconditional method complete is invoked. By default, this method does nothing. You can distinguish cases by checking the identity of the given caller argument. If not equal to this, then it is typically a subtask that may contain results (and/or links to other results) to combine.

Parameters
caller:CountedCompleter<?>

Doc from java.util.concurrent.CountedCompleter.onCompletion.

the task invoking this method (which may be this task itself)

Annotations
@Override