Java 类java.util.function.DoublePredicate 实例源码

项目:CodeKatas    文件:PrimitiveFunctionalInterfaceTest.java   
@Test
public void DoublePredicate()
{
    // TODO - Convert the anonymous inner class to a lambda
    DoublePredicate predicate = new DoublePredicate()
    {
        @Override
        public boolean test(double value)
        {
            return value > 3.0;
        }
    };
    List<Double> greaterThan =
            DoubleStream.of(1.0, 2.0, 3.0, 4.0, 5.0).filter(predicate).boxed().collect(Collectors.toList());
    Assert.assertEquals(Arrays.asList(4.0d, 5.0d), greaterThan);
    List<Double> lessThanEqualTo =
            DoubleStream.of(1.0, 2.0, 3.0, 4.0, 5.0).filter(predicate.negate()).boxed().collect(Collectors.toList());
    Assert.assertEquals(Arrays.asList(1.0d, 2.0d, 3.0d), lessThanEqualTo);
    Assert.assertTrue(DoubleStream.of(1.0, 2.0, 3.0, 4.0, 5.0).anyMatch(predicate));
    Assert.assertFalse(DoubleStream.of(1.0, 2.0, 3.0, 4.0, 5.0).allMatch(predicate));
    Assert.assertFalse(DoubleStream.of(1.0, 2.0, 3.0, 4.0, 5.0).noneMatch(predicate));
}
项目:OpenJSharp    文件:DoublePipeline.java   
@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);
                }
            };
        }
    };
}
项目:OpenJSharp    文件:MatchOps.java   
/**
 * 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);
}
项目:jdk8u-jdk    文件:DoublePipeline.java   
@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);
                }
            };
        }
    };
}
项目:jdk8u-jdk    文件:MatchOps.java   
/**
 * 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);
}
项目:openjdk-jdk10    文件:DoublePipeline.java   
@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);
                }
            };
        }
    };
}
项目:openjdk-jdk10    文件:MatchOps.java   
/**
 * 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);
}
项目:openjdk9    文件:DoublePipeline.java   
@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);
                }
            };
        }
    };
}
项目:memoization.java    文件:ConcurrentMapBasedDoublePredicateMemoizerTest.java   
/**
*
*/
@Test
@SuppressWarnings(CompilerWarnings.UNUSED)
public void shouldRequireNonNullCache() {
    // given
    final ConcurrentMap<Double, Boolean> cache = null;
    final DoublePredicate predicate = input -> true;
    final DoubleFunction<Double> keyFunction = Double::valueOf;

    // when
    thrown.expect(NullPointerException.class);
    thrown.expectMessage("Provide an empty map instead of NULL.");

    // then
    new ConcurrentMapBasedDoublePredicateMemoizer<>(cache, keyFunction, predicate);
}
项目:openjdk9    文件:MatchOps.java   
/**
 * 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);
}
项目:memoization.java    文件:GuavaCacheBasedDoublePredicateMemoizerTest.java   
/**
 * @throws ExecutionException
 *             Added for the call to 'cache.get(..)'.
 */
@Test
@SuppressWarnings(CompilerWarnings.UNCHECKED)
public void shouldWrapExecutionExceptionInMemoizationException() throws ExecutionException {
    // given
    final DoublePredicate predicate = a -> true;
    final DoubleFunction<String> keyFunction = a -> "key";
    final Cache<String, Boolean> cache = Mockito.mock(Cache.class);
    given(cache.get(any(), any())).willThrow(ExecutionException.class);
    final GuavaCacheBasedDoublePredicateMemoizer<String> memoizer = new GuavaCacheBasedDoublePredicateMemoizer<>(
            cache, keyFunction, predicate);

    // when
    thrown.expect(MemoizationException.class);

    // then
    memoizer.test(123.456D);
}
项目:Java8CN    文件:DoublePipeline.java   
@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);
                }
            };
        }
    };
}
项目:Java8CN    文件:MatchOps.java   
/**
 * 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);
}
项目:jdk8u_jdk    文件:MatchOps.java   
/**
 * 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);
}
项目:lookaside_java-1.8.0-openjdk    文件:DoublePipeline.java   
@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);
                }
            };
        }
    };
}
项目:GameAuthoringEnvironment    文件:OnGlobalAttributeCondition.java   
public OnGlobalAttributeCondition (IGame game,
                                   AttributeType attributeType,
                                   DoublePredicate valueCheck,
                                   IEventPackage otherPackage,
                                   IEventPackage globalPackage) {
    myGame = game;
    myAttributeType = attributeType;
    myValueCheck = valueCheck;
    myOtherPackage = otherPackage;
    myGlobalPackage = globalPackage;
}
项目:GameAuthoringEnvironment    文件:OnSpriteAttributeCondition.java   
public OnSpriteAttributeCondition (IGame game,
                                   AttributeType attributeType,
                                   DoublePredicate valueCheck,
                                   IEventPackage spritePackage,
                                   IEventPackage otherPackage,
                                   IEventPackage globalPackage) {
    myGame = game;
    myAttributeType = attributeType;
    myValueCheck = valueCheck;
    mySpritePackage = spritePackage;
    myOtherPackage = otherPackage;
    myGlobalPackage = globalPackage;

}
项目:GameAuthoringEnvironment    文件:PredicateGenerator.java   
public DoublePredicate generateDouble (String value, String type) {
    double valToCompare = Double.parseDouble(value);
    if (type.equals("==")) {
        return new EqualsDoublePredicate(valToCompare);
    }
    else if (type.equals(">")) {
        return new GreaterThanDoublePredicate(valToCompare);
    }
    else {
        return new LessThanDoublePredicate(valToCompare);
    }

}
项目:openjdk-systemtest    文件:TestLambdaJavaInterfaces.java   
@Test public void testDoublePredicate() {
    DoublePredicate isCorrect = (d) -> {
        return d > 2894d;
    };

    assertTrue(isCorrect.test(2898d));
    assertFalse(isCorrect.test(2751d));
    assertFalse(isCorrect.test(38L));
}
项目:jdk8u-jdk    文件:MatchOpTest.java   
private void assertDoublePredicates(Supplier<DoubleStream> source, Kind kind, DoublePredicate[] predicates, boolean... answers) {
    for (int i = 0; i < predicates.length; i++) {
        setContext("i", i);
        boolean match = doubleKinds.get(kind).apply(predicates[i]).apply(source.get());
        assertEquals(answers[i], match, kind.toString() + predicates[i].toString());
    }
}
项目:jdk8u-jdk    文件:MatchOpTest.java   
@Test(dataProvider = "DoubleStreamTestData", dataProviderClass = DoubleStreamTestDataProvider.class)
public void testDoubleStream(String name, TestData.OfDouble data) {
    for (DoublePredicate p : DOUBLE_PREDICATES) {
        setContext("p", p);
        for (Kind kind : Kind.values()) {
            setContext("kind", kind);
            exerciseTerminalOps(data, doubleKinds.get(kind).apply(p));
            exerciseTerminalOps(data, s -> s.filter(dpFalse), doubleKinds.get(kind).apply(p));
            exerciseTerminalOps(data, s -> s.filter(dpEven), doubleKinds.get(kind).apply(p));
        }
    }
}
项目:openjdk-jdk10    文件:MatchOpTest.java   
private void assertDoublePredicates(Supplier<DoubleStream> source, Kind kind, DoublePredicate[] predicates, boolean... answers) {
    for (int i = 0; i < predicates.length; i++) {
        setContext("i", i);
        boolean match = doubleKinds.get(kind).apply(predicates[i]).apply(source.get());
        assertEquals(answers[i], match, kind.toString() + predicates[i].toString());
    }
}
项目:openjdk-jdk10    文件:MatchOpTest.java   
@Test(dataProvider = "DoubleStreamTestData", dataProviderClass = DoubleStreamTestDataProvider.class)
public void testDoubleStream(String name, TestData.OfDouble data) {
    for (DoublePredicate p : DOUBLE_PREDICATES) {
        setContext("p", p);
        for (Kind kind : Kind.values()) {
            setContext("kind", kind);
            exerciseTerminalOps(data, doubleKinds.get(kind).apply(p));
            exerciseTerminalOps(data, s -> s.filter(dpFalse), doubleKinds.get(kind).apply(p));
            exerciseTerminalOps(data, s -> s.filter(dpEven), doubleKinds.get(kind).apply(p));
        }
    }
}
项目:test-as-you-think    文件:ResultOfEventTest.java   
@Test
public void should_verify_an_actual_double_predicate_is_conform_to_an_expected_result() {
    assertThat(resultOf(() -> {
        gwtMock.whenAnEventHappensInRelationToAnActionOfTheConsumer();
        return (DoublePredicate) number -> number < 100;
    }).accepts(99)).hasSameClassAs(assertThat((DoublePredicate) t -> t == 0));
}
项目:morpheus-core    文件:RangeOfDoubles.java   
/**
 * Constructor
 * @param start     the start for range, inclusive
 * @param end       the end for range, exclusive
 * @param step      the step increment
 * @param excludes  optional predicate to exclude elements in this range
 */
RangeOfDoubles(double start, double end, double step, DoublePredicate excludes) {
    super(start, end);
    this.start = start;
    this.end = end;
    this.step = step;
    this.ascend = start <= end;
    this.excludes = excludes;
}
项目:memoization.java    文件:JCacheBasedDoublePredicateMemoizer.java   
JCacheBasedDoublePredicateMemoizer(
        final Cache<KEY, Boolean> cache,
        final DoubleFunction<KEY> keyFunction,
        final DoublePredicate predicate) {
    super(cache);
    this.keyFunction = keyFunction;
    this.predicate = predicate;
}
项目:memoization.java    文件:ConcurrentMapBasedDoublePredicateMemoizer.java   
@SuppressWarnings(CompilerWarnings.NLS)
ConcurrentMapBasedDoublePredicateMemoizer(
        final ConcurrentMap<KEY, Boolean> cache,
        final DoubleFunction<KEY> keyFunction,
        final DoublePredicate predicate) {
    super(cache);
    this.keyFunction = keyFunction;
    this.predicate = requireNonNull(predicate,
            "Cannot memoize a NULL Predicate - provide an actual Predicate to fix this.");
}
项目:openjdk9    文件:MatchOpTest.java   
private void assertDoublePredicates(Supplier<DoubleStream> source, Kind kind, DoublePredicate[] predicates, boolean... answers) {
    for (int i = 0; i < predicates.length; i++) {
        setContext("i", i);
        boolean match = doubleKinds.get(kind).apply(predicates[i]).apply(source.get());
        assertEquals(answers[i], match, kind.toString() + predicates[i].toString());
    }
}
项目:openjdk9    文件:MatchOpTest.java   
@Test(dataProvider = "DoubleStreamTestData", dataProviderClass = DoubleStreamTestDataProvider.class)
public void testDoubleStream(String name, TestData.OfDouble data) {
    for (DoublePredicate p : DOUBLE_PREDICATES) {
        setContext("p", p);
        for (Kind kind : Kind.values()) {
            setContext("kind", kind);
            exerciseTerminalOps(data, doubleKinds.get(kind).apply(p));
            exerciseTerminalOps(data, s -> s.filter(dpFalse), doubleKinds.get(kind).apply(p));
            exerciseTerminalOps(data, s -> s.filter(dpEven), doubleKinds.get(kind).apply(p));
        }
    }
}
项目:throwable-interfaces    文件:DoublePredicateWithThrowable.java   
/**
 * @throws E if an exception E has been thrown, it is rethrown by this method
 * @return An interface that is only returned if no exception has been thrown.
 */
default DoublePredicate thatUnsafelyThrowsUnchecked() throws E {
  return (final double v1) -> {
    try {
      return testWithThrowable(v1);
    } catch(final Throwable throwable) {
       SuppressedException.throwUnsafelyAsUnchecked(throwable);
       return false;        }
  };
}
项目:SOAPgaea    文件:GvcfMathUtils.java   
/**
 * Test whether all elements of a double[] array satisfy a double -> boolean predicate
 */
public static boolean allMatch(final double[] array, final DoublePredicate pred) {
    JointCallingUtils.nonNull(array, "array may not be null");
    JointCallingUtils.nonNull(pred, "predicate may not be null");
    for (final double x : array) {
        if (!pred.test(x)) {
            return false;
        }
    }
    return true;
}
项目:validity    文件:ValidityUtilsTest.java   
@Test
void testDescribeDoublePredicateReturnsExpectedStringForNonDescriptive() {
    DoublePredicate predicate = t -> t > 0;
    Assertions.assertEquals(ValidityUtils.unknownPredicatePrefix() + predicate.toString(),
                            ValidityUtils.describe(predicate),
                            "Non descriptive predicate should be consistently described.");
}
项目:validity    文件:DescriptiveDoublePredicateTest.java   
@Test
void testDescriptiveDoublePredicateHasExpectedPredicate() {
    DoublePredicate predicate = getNotValueTypeInstance();
    Assertions.assertAll("DescriptiveDoublePredicate should wrap the expected predicate.",
                         () -> Assertions.assertTrue(predicate.test(1.0)),
                         () -> Assertions.assertFalse(predicate.test(0.0)),
                         () -> Assertions.assertFalse(predicate.test(-1.0)));
}
项目:memoization.java    文件:JCacheMemoizeCustomKeyTest.java   
/**
*
*/
@Test
public void shouldMemoizeDoublePredicateWithKeyFunction() {
    // given
    final DoublePredicate predicate = a -> true;
    final DoubleFunction<String> keyFunction = a -> "key";

    // when
    final DoublePredicate memoize = JCacheMemoize.doublePredicate(predicate, keyFunction);

    // then
    Assert.assertNotNull("Memoized DoublePredicate is NULL", memoize);
}
项目:validity    文件:DescriptiveDoublePredicateTest.java   
@Test
void testDescriptiveDoublePredicateAndHasExpectedPredicate() {
    DoublePredicate other = new DescriptiveDoublePredicate("10 > " + AbstractDescriptivePredicate.TOKEN, t -> 10 > t);
    DoublePredicate predicate = getNotValueTypeInstance().and(other);
    Assertions.assertAll("DescriptiveDoublePredicate should wrap the expected predicate.",
                         () -> Assertions.assertFalse(predicate.test(-1.0)),
                         () -> Assertions.assertFalse(predicate.test(0.0)),
                         () -> Assertions.assertTrue(predicate.test(1.0)),
                         () -> Assertions.assertTrue(predicate.test(9.0)),
                         () -> Assertions.assertFalse(predicate.test(10.0)));
}
项目:memoization.java    文件:CaffeineMemoizeLambdaTest.java   
/**
*
*/
@Test
public void shouldMemoizeDoublePredicateWithLambda() {
    // given

    // when
    final DoublePredicate memoize = CaffeineMemoize.doublePredicate(a -> true);

    // then
    Assert.assertNotNull("Memoized DoublePredicate is NULL", memoize);
}
项目:parallel-stream-support    文件:ParallelDoubleStreamSupportTest.java   
@Test
public void filter() {
  DoublePredicate p = d -> true;
  DoubleStream stream = this.parallelStreamSupportMock.filter(p);

  verify(this.delegateMock).filter(p);
  assertSame(this.parallelStreamSupportMock, stream);
}
项目:memoization.java    文件:MapMemoizeLambdaTest.java   
/**
*
*/
@Test
public void shouldMemoizeDoublePredicateWithLambda() {
    // given

    // when
    final DoublePredicate memoize = MapMemoize.doublePredicate(input -> true);

    // then
    Assert.assertNotNull("Memoized DoublePredicate is NULL", memoize);
}
项目:memoization.java    文件:JCacheMemoizeDefaultsTest.java   
/**
*
*/
@Test
public void shouldMemoizeDoublePredicate() {
    // given
    final DoublePredicate predicate = a -> true;

    // when
    final DoublePredicate memoize = JCacheMemoize.doublePredicate(predicate);

    // then
    Assert.assertNotNull("Memoized DoublePredicate is NULL", memoize);
}
项目:memoization.java    文件:ConcurrentMapBasedDoublePredicateMemoizerTest.java   
/**
*
*/
@Test
public void shouldMemoizePredicateCall() {
    // given
    final ConcurrentMap<Double, Boolean> cache = new ConcurrentHashMap<>();
    final DoublePredicate predicate = input -> true;
    final DoubleFunction<Double> keyFunction = Double::valueOf;

    // when
    final ConcurrentMapBasedDoublePredicateMemoizer<Double> memoizer = new ConcurrentMapBasedDoublePredicateMemoizer<>(
            cache, keyFunction, predicate);

    // then
    Assert.assertTrue("Memoized value does not match expectations", memoizer.test(123.456D));
}