Java Code Examples for java.util.function.DoublePredicate#test()
The following examples show how to use
java.util.function.DoublePredicate#test() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MatchOps.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
/** * Constructs a quantified predicate matcher for a {@code DoubleStream}. * * @param predicate the {@code Predicate} to apply to stream elements * @param matchKind the kind of quantified match (all, any, none) * @return a {@code TerminalOp} implementing the desired quantified match * criteria */ public static TerminalOp<Double, Boolean> makeDouble(DoublePredicate predicate, MatchKind matchKind) { Objects.requireNonNull(predicate); Objects.requireNonNull(matchKind); class MatchSink extends BooleanTerminalSink<Double> implements Sink.OfDouble { MatchSink() { super(matchKind); } @Override public void accept(double t) { if (!stop && predicate.test(t) == matchKind.stopOnPredicateMatches) { stop = true; value = matchKind.shortCircuitResult; } } } return new MatchOp<>(StreamShape.DOUBLE_VALUE, matchKind, MatchSink::new); }
Example 2
Source File: MatchOps.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * Constructs a quantified predicate matcher for a {@code DoubleStream}. * * @param predicate the {@code Predicate} to apply to stream elements * @param matchKind the kind of quantified match (all, any, none) * @return a {@code TerminalOp} implementing the desired quantified match * criteria */ public static TerminalOp<Double, Boolean> makeDouble(DoublePredicate predicate, MatchKind matchKind) { Objects.requireNonNull(predicate); Objects.requireNonNull(matchKind); class MatchSink extends BooleanTerminalSink<Double> implements Sink.OfDouble { MatchSink() { super(matchKind); } @Override public void accept(double t) { if (!stop && predicate.test(t) == matchKind.stopOnPredicateMatches) { stop = true; value = matchKind.shortCircuitResult; } } } return new MatchOp<>(StreamShape.DOUBLE_VALUE, matchKind, MatchSink::new); }
Example 3
Source File: DoublePipeline.java From Bytecoder with Apache License 2.0 | 6 votes |
@Override public final DoubleStream filter(DoublePredicate predicate) { Objects.requireNonNull(predicate); return new StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE, StreamOpFlag.NOT_SIZED) { @Override Sink<Double> opWrapSink(int flags, Sink<Double> sink) { return new Sink.ChainedDouble<Double>(sink) { @Override public void begin(long size) { downstream.begin(-1); } @Override public void accept(double t) { if (predicate.test(t)) downstream.accept(t); } }; } }; }
Example 4
Source File: DoublePipeline.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Override public final DoubleStream filter(DoublePredicate predicate) { Objects.requireNonNull(predicate); return new StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE, StreamOpFlag.NOT_SIZED) { @Override Sink<Double> opWrapSink(int flags, Sink<Double> sink) { return new Sink.ChainedDouble<Double>(sink) { @Override public void begin(long size) { downstream.begin(-1); } @Override public void accept(double t) { if (predicate.test(t)) downstream.accept(t); } }; } }; }
Example 5
Source File: DoublePipeline.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@Override public final DoubleStream filter(DoublePredicate predicate) { Objects.requireNonNull(predicate); return new StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE, StreamOpFlag.NOT_SIZED) { @Override Sink<Double> opWrapSink(int flags, Sink<Double> sink) { return new Sink.ChainedDouble<Double>(sink) { @Override public void begin(long size) { downstream.begin(-1); } @Override public void accept(double t) { if (predicate.test(t)) downstream.accept(t); } }; } }; }
Example 6
Source File: MatchOps.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Constructs a quantified predicate matcher for a {@code DoubleStream}. * * @param predicate the {@code Predicate} to apply to stream elements * @param matchKind the kind of quantified match (all, any, none) * @return a {@code TerminalOp} implementing the desired quantified match * criteria */ public static TerminalOp<Double, Boolean> makeDouble(DoublePredicate predicate, MatchKind matchKind) { Objects.requireNonNull(predicate); Objects.requireNonNull(matchKind); class MatchSink extends BooleanTerminalSink<Double> implements Sink.OfDouble { MatchSink() { super(matchKind); } @Override public void accept(double t) { if (!stop && predicate.test(t) == matchKind.stopOnPredicateMatches) { stop = true; value = matchKind.shortCircuitResult; } } } return new MatchOp<>(StreamShape.DOUBLE_VALUE, matchKind, MatchSink::new); }
Example 7
Source File: DoublePipeline.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Override public final DoubleStream filter(DoublePredicate predicate) { Objects.requireNonNull(predicate); return new StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE, StreamOpFlag.NOT_SIZED) { @Override Sink<Double> opWrapSink(int flags, Sink<Double> sink) { return new Sink.ChainedDouble<Double>(sink) { @Override public void begin(long size) { downstream.begin(-1); } @Override public void accept(double t) { if (predicate.test(t)) downstream.accept(t); } }; } }; }
Example 8
Source File: MatchOps.java From desugar_jdk_libs with GNU General Public License v2.0 | 6 votes |
/** * Constructs a quantified predicate matcher for a {@code DoubleStream}. * * @param predicate the {@code Predicate} to apply to stream elements * @param matchKind the kind of quantified match (all, any, none) * @return a {@code TerminalOp} implementing the desired quantified match * criteria */ public static TerminalOp<Double, Boolean> makeDouble(DoublePredicate predicate, MatchKind matchKind) { Objects.requireNonNull(predicate); Objects.requireNonNull(matchKind); class MatchSink extends BooleanTerminalSink<Double> implements Sink.OfDouble { MatchSink() { super(matchKind); } @Override public void accept(double t) { if (!stop && predicate.test(t) == matchKind.stopOnPredicateMatches) { stop = true; value = matchKind.shortCircuitResult; } } } return new MatchOp<>(StreamShape.DOUBLE_VALUE, matchKind, MatchSink::new); }
Example 9
Source File: DoublePipeline.java From desugar_jdk_libs with GNU General Public License v2.0 | 6 votes |
@Override public final DoubleStream filter(DoublePredicate predicate) { Objects.requireNonNull(predicate); return new StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE, StreamOpFlag.NOT_SIZED) { @Override Sink<Double> opWrapSink(int flags, Sink<Double> sink) { return new Sink.ChainedDouble<Double>(sink) { @Override public void begin(long size) { downstream.begin(-1); } @Override public void accept(double t) { if (predicate.test(t)) downstream.accept(t); } }; } }; }
Example 10
Source File: DoublePipeline.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Override public final DoubleStream filter(DoublePredicate predicate) { Objects.requireNonNull(predicate); return new StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE, StreamOpFlag.NOT_SIZED) { @Override Sink<Double> opWrapSink(int flags, Sink<Double> sink) { return new Sink.ChainedDouble<Double>(sink) { @Override public void begin(long size) { downstream.begin(-1); } @Override public void accept(double t) { if (predicate.test(t)) downstream.accept(t); } }; } }; }
Example 11
Source File: DoublePipeline.java From JDKSourceCode1.8 with MIT License | 6 votes |
@Override public final DoubleStream filter(DoublePredicate predicate) { Objects.requireNonNull(predicate); return new StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE, StreamOpFlag.NOT_SIZED) { @Override Sink<Double> opWrapSink(int flags, Sink<Double> sink) { return new Sink.ChainedDouble<Double>(sink) { @Override public void begin(long size) { downstream.begin(-1); } @Override public void accept(double t) { if (predicate.test(t)) downstream.accept(t); } }; } }; }
Example 12
Source File: MatchOps.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Constructs a quantified predicate matcher for a {@code DoubleStream}. * * @param predicate the {@code Predicate} to apply to stream elements * @param matchKind the kind of quantified match (all, any, none) * @return a {@code TerminalOp} implementing the desired quantified match * criteria */ public static TerminalOp<Double, Boolean> makeDouble(DoublePredicate predicate, MatchKind matchKind) { Objects.requireNonNull(predicate); Objects.requireNonNull(matchKind); class MatchSink extends BooleanTerminalSink<Double> implements Sink.OfDouble { MatchSink() { super(matchKind); } @Override public void accept(double t) { if (!stop && predicate.test(t) == matchKind.stopOnPredicateMatches) { stop = true; value = matchKind.shortCircuitResult; } } } return new MatchOp<>(StreamShape.DOUBLE_VALUE, matchKind, MatchSink::new); }
Example 13
Source File: DoublePipeline.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Override public final DoubleStream filter(DoublePredicate predicate) { Objects.requireNonNull(predicate); return new StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE, StreamOpFlag.NOT_SIZED) { @Override Sink<Double> opWrapSink(int flags, Sink<Double> sink) { return new Sink.ChainedDouble<Double>(sink) { @Override public void begin(long size) { downstream.begin(-1); } @Override public void accept(double t) { if (predicate.test(t)) downstream.accept(t); } }; } }; }
Example 14
Source File: MatchOps.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Constructs a quantified predicate matcher for a {@code DoubleStream}. * * @param predicate the {@code Predicate} to apply to stream elements * @param matchKind the kind of quantified match (all, any, none) * @return a {@code TerminalOp} implementing the desired quantified match * criteria */ public static TerminalOp<Double, Boolean> makeDouble(DoublePredicate predicate, MatchKind matchKind) { Objects.requireNonNull(predicate); Objects.requireNonNull(matchKind); class MatchSink extends BooleanTerminalSink<Double> implements Sink.OfDouble { MatchSink() { super(matchKind); } @Override public void accept(double t) { if (!stop && predicate.test(t) == matchKind.stopOnPredicateMatches) { stop = true; value = matchKind.shortCircuitResult; } } } return new MatchOp<>(StreamShape.DOUBLE_VALUE, matchKind, MatchSink::new); }
Example 15
Source File: DoublePipeline.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Override public final DoubleStream filter(DoublePredicate predicate) { Objects.requireNonNull(predicate); return new StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE, StreamOpFlag.NOT_SIZED) { @Override Sink<Double> opWrapSink(int flags, Sink<Double> sink) { return new Sink.ChainedDouble<Double>(sink) { @Override public void begin(long size) { downstream.begin(-1); } @Override public void accept(double t) { if (predicate.test(t)) downstream.accept(t); } }; } }; }
Example 16
Source File: MatchOps.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * Constructs a quantified predicate matcher for a {@code DoubleStream}. * * @param predicate the {@code Predicate} to apply to stream elements * @param matchKind the kind of quantified match (all, any, none) * @return a {@code TerminalOp} implementing the desired quantified match * criteria */ public static TerminalOp<Double, Boolean> makeDouble(DoublePredicate predicate, MatchKind matchKind) { Objects.requireNonNull(predicate); Objects.requireNonNull(matchKind); class MatchSink extends BooleanTerminalSink<Double> implements Sink.OfDouble { MatchSink() { super(matchKind); } @Override public void accept(double t) { if (!stop && predicate.test(t) == matchKind.stopOnPredicateMatches) { stop = true; value = matchKind.shortCircuitResult; } } } return new MatchOp<>(StreamShape.DOUBLE_VALUE, matchKind, MatchSink::new); }
Example 17
Source File: DoublePipeline.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
@Override public final DoubleStream filter(DoublePredicate predicate) { Objects.requireNonNull(predicate); return new StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE, StreamOpFlag.NOT_SIZED) { @Override Sink<Double> opWrapSink(int flags, Sink<Double> sink) { return new Sink.ChainedDouble<Double>(sink) { @Override public void begin(long size) { downstream.begin(-1); } @Override public void accept(double t) { if (predicate.test(t)) downstream.accept(t); } }; } }; }
Example 18
Source File: MatchOps.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Constructs a quantified predicate matcher for a {@code DoubleStream}. * * @param predicate the {@code Predicate} to apply to stream elements * @param matchKind the kind of quantified match (all, any, none) * @return a {@code TerminalOp} implementing the desired quantified match * criteria */ public static TerminalOp<Double, Boolean> makeDouble(DoublePredicate predicate, MatchKind matchKind) { Objects.requireNonNull(predicate); Objects.requireNonNull(matchKind); class MatchSink extends BooleanTerminalSink<Double> implements Sink.OfDouble { MatchSink() { super(matchKind); } @Override public void accept(double t) { if (!stop && predicate.test(t) == matchKind.stopOnPredicateMatches) { stop = true; value = matchKind.shortCircuitResult; } } } return new MatchOp<>(StreamShape.DOUBLE_VALUE, matchKind, MatchSink::new); }
Example 19
Source File: VerifyHelper.java From Launcher with GNU General Public License v3.0 | 4 votes |
public static double verifyDouble(double d, DoublePredicate predicate, String error) { if (predicate.test(d)) return d; throw new IllegalArgumentException(error); }
Example 20
Source File: OptionalDouble.java From metanome-algorithms with Apache License 2.0 | 4 votes |
public OptionalDouble filter(@NonNull DoublePredicate predicate) { if (!optional.isPresent()) { return this; } return predicate.test(optional.getAsDouble()) ? this : empty(); }