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

pack-priv final Class MatchOps

extends Object
Class Inheritance
Imports
java.util.Objects, .Spliterator, java.util.function.DoublePredicate, .IntPredicate, .LongPredicate, .Predicate, .Supplier

Factory for instances of a short-circuiting TerminalOp that implement quantified predicate matching on the elements of a stream. Supported variants include match-all, match-any, and match-none.
Since
1.8

Nested and Inner Type Summary

Modifier and TypeClass and Description
private abstract static class
MatchOps.BooleanTerminalSink<
The output type of the stream pipeline
T
>

Boolean specific terminal sink to avoid the boxing costs when returning results.

pack-priv static enum
MatchOps.MatchKind

Enum describing quantified match options -- all match, any match, none match.

private static class
MatchOps.MatchOp<
the output type of the stream pipeline
T
>

A short-circuiting TerminalOp that evaluates a predicate on the elements of a stream and determines whether all, any or none of those elements match the predicate.

private static class
MatchOps.MatchTask<
the type of source elements for the pipeline
P_IN
,
the type of output elements for the pipeline
P_OUT
>

ForkJoinTask implementation to implement a parallel short-circuiting quantified match

Constructor Summary

AccessConstructor and Description
private

Method Summary

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

Returns:

a TerminalOp implementing the desired quantified match criteria
makeDouble
(DoublePredicate
the Predicate to apply to stream elements
predicate
,
MatchOps.MatchKind
the kind of quantified match (all, any, none)
matchKind
)

Constructs a quantified predicate matcher for a DoubleStream.

public static TerminalOp<Integer, Boolean>

Returns:

a TerminalOp implementing the desired quantified match criteria
makeInt
(IntPredicate
the Predicate to apply to stream elements
predicate
,
MatchOps.MatchKind
the kind of quantified match (all, any, none)
matchKind
)

Constructs a quantified predicate matcher for an IntStream.

public static TerminalOp<Long, Boolean>

Returns:

a TerminalOp implementing the desired quantified match criteria
makeLong
(LongPredicate
the Predicate to apply to stream elements
predicate
,
MatchOps.MatchKind
the kind of quantified match (all, any, none)
matchKind
)

Constructs a quantified predicate matcher for a LongStream.

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

Returns:

a TerminalOp implementing the desired quantified match criteria
makeRef
(Predicate<? super T>
the Predicate to apply to stream elements
predicate
,
MatchOps.MatchKind
the kind of quantified match (all, any, none)
matchKind
)

Constructs a quantified predicate matcher for a Stream.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

MatchOpsback to summary
private MatchOps()

Method Detail

makeDoubleback to summary
public static TerminalOp<Double, Boolean> makeDouble(DoublePredicate predicate, MatchOps.MatchKind matchKind)

Constructs a quantified predicate matcher for a DoubleStream.

Parameters
predicate:DoublePredicate

the Predicate to apply to stream elements

matchKind:MatchOps.MatchKind

the kind of quantified match (all, any, none)

Returns:TerminalOp<Double, Boolean>

a TerminalOp implementing the desired quantified match criteria

makeIntback to summary
public static TerminalOp<Integer, Boolean> makeInt(IntPredicate predicate, MatchOps.MatchKind matchKind)

Constructs a quantified predicate matcher for an IntStream.

Parameters
predicate:IntPredicate

the Predicate to apply to stream elements

matchKind:MatchOps.MatchKind

the kind of quantified match (all, any, none)

Returns:TerminalOp<Integer, Boolean>

a TerminalOp implementing the desired quantified match criteria

makeLongback to summary
public static TerminalOp<Long, Boolean> makeLong(LongPredicate predicate, MatchOps.MatchKind matchKind)

Constructs a quantified predicate matcher for a LongStream.

Parameters
predicate:LongPredicate

the Predicate to apply to stream elements

matchKind:MatchOps.MatchKind

the kind of quantified match (all, any, none)

Returns:TerminalOp<Long, Boolean>

a TerminalOp implementing the desired quantified match criteria

makeRefback to summary
public static <T> TerminalOp<T, Boolean> makeRef(Predicate<? super T> predicate, MatchOps.MatchKind matchKind)

Constructs a quantified predicate matcher for a Stream.

Parameters
<T>
the type of stream elements
predicate:Predicate<? super T>

the Predicate to apply to stream elements

matchKind:MatchOps.MatchKind

the kind of quantified match (all, any, none)

Returns:TerminalOp<T, Boolean>

a TerminalOp implementing the desired quantified match criteria

java.util.stream back to summary

private abstract Class MatchOps.BooleanTerminalSink<T>

extends Object
implements Sink<T>
Class Inheritance
All Implemented Interfaces
java.util.stream.Sink, java.util.function.Consumer
Type Parameters
<T>
The output type of the stream pipeline

Boolean specific terminal sink to avoid the boxing costs when returning results. Subclasses implement the shape-specific functionality.

Field Summary

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

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
cancellationRequested()

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

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

public boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

stopback to summary
pack-priv boolean stop
valueback to summary
pack-priv boolean value

Constructor Detail

BooleanTerminalSinkback to summary
pack-priv BooleanTerminalSink(MatchOps.MatchKind matchKind)

Method Detail

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.

Annotations
@Override
getAndClearStateback to summary
public boolean getAndClearState()
java.util.stream back to summary

pack-priv final Enum MatchOps.MatchKind

extends Enum<MatchOps.MatchKind>
Class Inheritance

Enum describing quantified match options -- all match, any match, none match.

Field Summary

Modifier and TypeField and Description
public static final MatchOps.MatchKind
ALL

Do all elements match the predicate?

public static final MatchOps.MatchKind
ANY

Do any elements match the predicate?

public static final MatchOps.MatchKind
NONE

Do no elements match the predicate?

private final boolean
private final boolean

Constructor Summary

AccessConstructor and Description
private
MatchKind(boolean stopOnPredicateMatches, boolean shortCircuitResult)

Method Summary

Modifier and TypeMethod and Description
public static MatchOps.MatchKind
public static MatchOps.MatchKind[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ALLback to summary
public static final MatchOps.MatchKind ALL

Do all elements match the predicate?

ANYback to summary
public static final MatchOps.MatchKind ANY

Do any elements match the predicate?

NONEback to summary
public static final MatchOps.MatchKind NONE

Do no elements match the predicate?

shortCircuitResultback to summary
private final boolean shortCircuitResult
stopOnPredicateMatchesback to summary
private final boolean stopOnPredicateMatches

Constructor Detail

MatchKindback to summary
private MatchKind(boolean stopOnPredicateMatches, boolean shortCircuitResult)

Method Detail

valueOfback to summary
public static MatchOps.MatchKind valueOf(String name)
valuesback to summary
public static MatchOps.MatchKind[] values()
java.util.stream back to summary

private final Class MatchOps.MatchOp<T>

extends Object
implements TerminalOp<T, Boolean>
Class Inheritance
All Implemented Interfaces
java.util.stream.TerminalOp
Type Parameters
<T>
the output type of the stream pipeline

A short-circuiting TerminalOp that evaluates a predicate on the elements of a stream and determines whether all, any or none of those elements match the predicate.

Field Summary

Modifier and TypeField and Description
private final StreamShape
pack-priv final MatchOps.MatchKind
pack-priv final Supplier<MatchOps.BooleanTerminalSink<T>>

Constructor Summary

AccessConstructor and Description
pack-priv
MatchOp(StreamShape
the output shape of the stream pipeline
shape
,
MatchOps.MatchKind
the kind of quantified match (all, any, none)
matchKind
,
Supplier<MatchOps.BooleanTerminalSink<T>>
Supplier for a Sink of the appropriate shape which implements the matching operation
sinkSupplier
)

Constructs a MatchOp.

Method Summary

Modifier and TypeMethod and Description
public <S> Boolean
evaluateParallel(PipelineHelper<T> helper, Spliterator<S> 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> Boolean
evaluateSequential(PipelineHelper<T> helper, Spliterator<S> 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

inputShapeback to summary
private final StreamShape inputShape
matchKindback to summary
pack-priv final MatchOps.MatchKind matchKind
sinkSupplierback to summary
pack-priv final Supplier<MatchOps.BooleanTerminalSink<T>> sinkSupplier

Constructor Detail

MatchOpback to summary
pack-priv MatchOp(StreamShape shape, MatchOps.MatchKind matchKind, Supplier<MatchOps.BooleanTerminalSink<T>> sinkSupplier)

Constructs a MatchOp.

Parameters
shape:StreamShape

the output shape of the stream pipeline

matchKind:MatchOps.MatchKind

the kind of quantified match (all, any, none)

sinkSupplier:Supplier<MatchOps.BooleanTerminalSink<T>>

Supplier for a Sink of the appropriate shape which implements the matching operation

Method Detail

evaluateParallelback to summary
public <S> Boolean evaluateParallel(PipelineHelper<T> helper, Spliterator<S> 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.

Annotations
@Override
evaluateSequentialback to summary
public <S> Boolean 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.

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.

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.

Annotations
@Override
java.util.stream back to summary

private final Class MatchOps.MatchTask<P_IN, P_OUT>

extends AbstractShortCircuitTask<P_IN, P_OUT, Boolean, MatchOps.MatchTask<P_IN, P_OUT>>
Class Inheritance
Annotations
@SuppressWarnings:serial
Type Parameters
<P_IN>
the type of source elements for the pipeline
<P_OUT>
the type of output elements for the pipeline

ForkJoinTask implementation to implement a parallel short-circuiting quantified match

Field Summary

Modifier and TypeField and Description
private final MatchOps.MatchOp<P_OUT>
Inherited from java.util.stream.AbstractShortCircuitTask:
canceledsharedResult

Constructor Summary

AccessConstructor and Description
pack-priv
MatchTask(MatchOps.MatchOp<P_OUT> op, PipelineHelper<P_OUT> helper, Spliterator<P_IN> spliterator)

Constructor for root node

pack-priv
MatchTask(MatchOps.MatchTask<P_IN, P_OUT> parent, Spliterator<P_IN> spliterator)

Constructor for non-root node

Method Summary

Modifier and TypeMethod and Description
protected Boolean
doLeaf()

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

Computes the result associated with a leaf node.

protected Boolean
getEmptyResult()

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

Returns the value indicating the computation completed with no task finding a short-circuitable result.

protected MatchOps.MatchTask<P_IN, P_OUT>
makeChild(Spliterator<P_IN> 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.

Inherited from java.util.stream.AbstractShortCircuitTask:
cancelcancelLaterNodescomputegetLocalResultgetRawResultsetLocalResultshortCircuittaskCanceled

Field Detail

opback to summary
private final MatchOps.MatchOp<P_OUT> op

Constructor Detail

MatchTaskback to summary
pack-priv MatchTask(MatchOps.MatchOp<P_OUT> op, PipelineHelper<P_OUT> helper, Spliterator<P_IN> spliterator)

Constructor for root node

MatchTaskback to summary
pack-priv MatchTask(MatchOps.MatchTask<P_IN, P_OUT> parent, Spliterator<P_IN> spliterator)

Constructor for non-root node

Method Detail

doLeafback to summary
protected Boolean 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()

Annotations
@Override
getEmptyResultback to summary
protected Boolean 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.

Annotations
@Override
makeChildback to summary
protected MatchOps.MatchTask<P_IN, P_OUT> 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.

Annotations
@Override