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

项目:memoization.java    文件:GuavaCacheBasedObjDoubleConsumerMemoizerTest.java   
/**
*
*/
@Test
@SuppressWarnings(CompilerWarnings.UNCHECKED)
public void shouldAcceptInput() {
    // given
    final ObjDoubleConsumer<String> biConsumer = Mockito.mock(ObjDoubleConsumer.class);
    final ObjDoubleFunction<String, String> keyFunction = (first, second) -> second + first;
    final Cache<String, String> cache = CacheBuilder.newBuilder().build();

    // when
    final GuavaCacheBasedObjDoubleConsumerMemoizer<String, String> memoizer = new GuavaCacheBasedObjDoubleConsumerMemoizer<>(
            cache, keyFunction, biConsumer);

    // then
    memoizer.accept("first", 123);
    Mockito.verify(biConsumer).accept("first", 123);
}
项目:memoization.java    文件:JCacheBasedObjDoubleConsumerMemoizerTest.java   
/**
*
*/
@Test
@SuppressWarnings(CompilerWarnings.UNCHECKED)
public void shouldAcceptInput() {
    // given
    final ObjDoubleConsumer<String> biConsumer = Mockito.mock(ObjDoubleConsumer.class);
    final ObjDoubleFunction<String, String> keyfunction = (a, b) -> "key";
    try (final Cache<String, String> cache = JCacheMemoize.createCache(BiConsumer.class)) {
        // when
        final JCacheBasedObjDoubleConsumerMemoizer<String, String> memoizer = new JCacheBasedObjDoubleConsumerMemoizer<>(
                cache, keyfunction, biConsumer);

        // then
        memoizer.accept("first", 123);
        Mockito.verify(biConsumer).accept("first", 123);
    }
}
项目:memoization.java    文件:ConcurrentMapBasedObjDoubleConsumerMemoizerTest.java   
/**
*
*/
@Test
@SuppressWarnings(CompilerWarnings.UNUSED)
public void shouldRequireNonNullCache() {
    // given
    final ConcurrentMap<String, String> cache = null;
    final ObjDoubleFunction<String, String> keyFunction = (first, second) -> first + second;
    final ObjDoubleConsumer<String> consumer = (first, second) -> System.out.println(first + second);

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

    // then
    new ConcurrentMapBasedObjDoubleConsumerMemoizer<>(cache, keyFunction, consumer);
}
项目:memoization.java    文件:ConcurrentMapBasedObjDoubleConsumerMemoizerTest.java   
/**
*
*/
@Test
@SuppressWarnings(CompilerWarnings.UNUSED)
public void shouldRequireNonNullKeyFunction() {
    // given
    final ConcurrentMap<String, String> cache = new ConcurrentHashMap<>();
    final ObjDoubleFunction<String, String> keyFunction = null;
    final ObjDoubleConsumer<String> consumer = (first, second) -> System.out.println(first + second);

    // when
    thrown.expect(NullPointerException.class);
    thrown.expectMessage(
            "Provide a key function, might just be 'MemoizationDefaults.objDoubleConsumerHashCodeKeyFunction()'.");

    // then
    new ConcurrentMapBasedObjDoubleConsumerMemoizer<>(cache, keyFunction, consumer);
}
项目:memoization.java    文件:ConcurrentMapBasedObjDoubleConsumerMemoizerTest.java   
/**
*
*/
@Test
@SuppressWarnings(CompilerWarnings.UNUSED)
public void shouldRequireNonNullConsumer() {
    // given
    final ConcurrentMap<String, String> cache = new ConcurrentHashMap<>();
    final ObjDoubleFunction<String, String> keyFunction = (first, second) -> first + second;
    final ObjDoubleConsumer<String> consumer = null;

    // when
    thrown.expect(NullPointerException.class);
    thrown.expectMessage("Cannot memoize a NULL Consumer - provide an actual Consumer to fix this.");

    // then
    new ConcurrentMapBasedObjDoubleConsumerMemoizer<>(cache, keyFunction, consumer);
}
项目:memoization.java    文件:ConcurrentMapBasedObjDoubleConsumerMemoizerTest.java   
/**
*
*/
@Test
public void shouldUseSetCacheKeyAndValue() {
    // given
    final ConcurrentMap<String, String> cache = new ConcurrentHashMap<>();
    final ObjDoubleFunction<String, String> keyFunction = (first, second) -> first + second;
    final ObjDoubleConsumer<String> consumer = (first, second) -> System.out.println(first + second);

    // when
    final ConcurrentMapBasedObjDoubleConsumerMemoizer<String, String> memoizer = new ConcurrentMapBasedObjDoubleConsumerMemoizer<>(
            cache, keyFunction, consumer);

    // then
    memoizer.accept("test", 123.456D);
    Assert.assertFalse("Cache is still empty after memoization", memoizer.viewCacheForTest().isEmpty());
    Assert.assertEquals("Memoization key does not match expectations", "test123.456",
            memoizer.viewCacheForTest().keySet().iterator().next());
    Assert.assertEquals("Memoization value does not match expectations", "test",
            memoizer.viewCacheForTest().values().iterator().next());
}
项目:memoization.java    文件:ConcurrentMapBasedObjDoubleConsumerMemoizerTest.java   
/**
*
*/
@Test
@SuppressWarnings(CompilerWarnings.UNCHECKED)
public void shouldUseCallWrappedConsumer() {
    // given
    final ConcurrentMap<String, String> cache = new ConcurrentHashMap<>();
    final ObjDoubleFunction<String, String> keyFunction = (first, second) -> first + second;
    final ObjDoubleConsumer<String> consumer = Mockito.mock(ObjDoubleConsumer.class);

    // when
    final ConcurrentMapBasedObjDoubleConsumerMemoizer<String, String> memoizer = new ConcurrentMapBasedObjDoubleConsumerMemoizer<>(
            cache, keyFunction, consumer);

    // then
    memoizer.accept("test", 123.456D);
    Mockito.verify(consumer).accept("test", 123.456D);
}
项目:jOOL    文件:CheckedBiConsumerTest.java   
@Test
public void testCheckedObjDoubleConsumer() {
    final CheckedObjDoubleConsumer<Object> objDoubleConsumer = (o1, o2) -> {
        throw new Exception(o1 + ":" + o2);
    };

    ObjDoubleConsumer<Object> c1 = Unchecked.objDoubleConsumer(objDoubleConsumer);
    ObjDoubleConsumer<Object> c2 = CheckedObjDoubleConsumer.unchecked(objDoubleConsumer);
    ObjDoubleConsumer<Object> c3 = Sneaky.objDoubleConsumer(objDoubleConsumer);
    ObjDoubleConsumer<Object> c4 = CheckedObjDoubleConsumer.sneaky(objDoubleConsumer);

    assertObjDoubleConsumer(c1, UncheckedException.class);
    assertObjDoubleConsumer(c2, UncheckedException.class);
    assertObjDoubleConsumer(c3, Exception.class);
    assertObjDoubleConsumer(c4, Exception.class);
}
项目:OpenJSharp    文件:ReduceOps.java   
/**
 * Constructs a {@code TerminalOp} that implements a mutable reduce on
 * {@code double} values.
 *
 * @param <R> the type of the result
 * @param supplier a factory to produce a new accumulator of the result type
 * @param accumulator a function to incorporate an int into an
 *        accumulator
 * @param combiner a function to combine an accumulator into another
 * @return a {@code TerminalOp} implementing the reduction
 */
public static <R> TerminalOp<Double, R>
makeDouble(Supplier<R> supplier,
           ObjDoubleConsumer<R> accumulator,
           BinaryOperator<R> combiner) {
    Objects.requireNonNull(supplier);
    Objects.requireNonNull(accumulator);
    Objects.requireNonNull(combiner);
    class ReducingSink extends Box<R>
            implements AccumulatingSink<Double, R, ReducingSink>, Sink.OfDouble {
        @Override
        public void begin(long size) {
            state = supplier.get();
        }

        @Override
        public void accept(double t) {
            accumulator.accept(state, t);
        }

        @Override
        public void combine(ReducingSink other) {
            state = combiner.apply(state, other.state);
        }
    }
    return new ReduceOp<Double, R, ReducingSink>(StreamShape.DOUBLE_VALUE) {
        @Override
        public ReducingSink makeSink() {
            return new ReducingSink();
        }
    };
}
项目:OpenJSharp    文件:DoublePipeline.java   
@Override
public final <R> R collect(Supplier<R> supplier,
                           ObjDoubleConsumer<R> accumulator,
                           BiConsumer<R, R> combiner) {
    BinaryOperator<R> operator = (left, right) -> {
        combiner.accept(left, right);
        return left;
    };
    return evaluate(ReduceOps.makeDouble(supplier, accumulator, operator));
}
项目:jdk8u-jdk    文件:ReduceOps.java   
/**
 * Constructs a {@code TerminalOp} that implements a mutable reduce on
 * {@code double} values.
 *
 * @param <R> the type of the result
 * @param supplier a factory to produce a new accumulator of the result type
 * @param accumulator a function to incorporate an int into an
 *        accumulator
 * @param combiner a function to combine an accumulator into another
 * @return a {@code TerminalOp} implementing the reduction
 */
public static <R> TerminalOp<Double, R>
makeDouble(Supplier<R> supplier,
           ObjDoubleConsumer<R> accumulator,
           BinaryOperator<R> combiner) {
    Objects.requireNonNull(supplier);
    Objects.requireNonNull(accumulator);
    Objects.requireNonNull(combiner);
    class ReducingSink extends Box<R>
            implements AccumulatingSink<Double, R, ReducingSink>, Sink.OfDouble {
        @Override
        public void begin(long size) {
            state = supplier.get();
        }

        @Override
        public void accept(double t) {
            accumulator.accept(state, t);
        }

        @Override
        public void combine(ReducingSink other) {
            state = combiner.apply(state, other.state);
        }
    }
    return new ReduceOp<Double, R, ReducingSink>(StreamShape.DOUBLE_VALUE) {
        @Override
        public ReducingSink makeSink() {
            return new ReducingSink();
        }
    };
}
项目:jdk8u-jdk    文件:DoublePipeline.java   
@Override
public final <R> R collect(Supplier<R> supplier,
                           ObjDoubleConsumer<R> accumulator,
                           BiConsumer<R, R> combiner) {
    BinaryOperator<R> operator = (left, right) -> {
        combiner.accept(left, right);
        return left;
    };
    return evaluate(ReduceOps.makeDouble(supplier, accumulator, operator));
}
项目:openjdk-jdk10    文件:ReduceOps.java   
/**
 * Constructs a {@code TerminalOp} that implements a mutable reduce on
 * {@code double} values.
 *
 * @param <R> the type of the result
 * @param supplier a factory to produce a new accumulator of the result type
 * @param accumulator a function to incorporate an int into an
 *        accumulator
 * @param combiner a function to combine an accumulator into another
 * @return a {@code TerminalOp} implementing the reduction
 */
public static <R> TerminalOp<Double, R>
makeDouble(Supplier<R> supplier,
           ObjDoubleConsumer<R> accumulator,
           BinaryOperator<R> combiner) {
    Objects.requireNonNull(supplier);
    Objects.requireNonNull(accumulator);
    Objects.requireNonNull(combiner);
    class ReducingSink extends Box<R>
            implements AccumulatingSink<Double, R, ReducingSink>, Sink.OfDouble {
        @Override
        public void begin(long size) {
            state = supplier.get();
        }

        @Override
        public void accept(double t) {
            accumulator.accept(state, t);
        }

        @Override
        public void combine(ReducingSink other) {
            state = combiner.apply(state, other.state);
        }
    }
    return new ReduceOp<Double, R, ReducingSink>(StreamShape.DOUBLE_VALUE) {
        @Override
        public ReducingSink makeSink() {
            return new ReducingSink();
        }
    };
}
项目:openjdk-jdk10    文件:DoublePipeline.java   
@Override
public final <R> R collect(Supplier<R> supplier,
                           ObjDoubleConsumer<R> accumulator,
                           BiConsumer<R, R> combiner) {
    Objects.requireNonNull(combiner);
    BinaryOperator<R> operator = (left, right) -> {
        combiner.accept(left, right);
        return left;
    };
    return evaluate(ReduceOps.makeDouble(supplier, accumulator, operator));
}
项目:openjdk9    文件:ReduceOps.java   
/**
 * Constructs a {@code TerminalOp} that implements a mutable reduce on
 * {@code double} values.
 *
 * @param <R> the type of the result
 * @param supplier a factory to produce a new accumulator of the result type
 * @param accumulator a function to incorporate an int into an
 *        accumulator
 * @param combiner a function to combine an accumulator into another
 * @return a {@code TerminalOp} implementing the reduction
 */
public static <R> TerminalOp<Double, R>
makeDouble(Supplier<R> supplier,
           ObjDoubleConsumer<R> accumulator,
           BinaryOperator<R> combiner) {
    Objects.requireNonNull(supplier);
    Objects.requireNonNull(accumulator);
    Objects.requireNonNull(combiner);
    class ReducingSink extends Box<R>
            implements AccumulatingSink<Double, R, ReducingSink>, Sink.OfDouble {
        @Override
        public void begin(long size) {
            state = supplier.get();
        }

        @Override
        public void accept(double t) {
            accumulator.accept(state, t);
        }

        @Override
        public void combine(ReducingSink other) {
            state = combiner.apply(state, other.state);
        }
    }
    return new ReduceOp<Double, R, ReducingSink>(StreamShape.DOUBLE_VALUE) {
        @Override
        public ReducingSink makeSink() {
            return new ReducingSink();
        }
    };
}
项目:openjdk9    文件:DoublePipeline.java   
@Override
public final <R> R collect(Supplier<R> supplier,
                           ObjDoubleConsumer<R> accumulator,
                           BiConsumer<R, R> combiner) {
    Objects.requireNonNull(combiner);
    BinaryOperator<R> operator = (left, right) -> {
        combiner.accept(left, right);
        return left;
    };
    return evaluate(ReduceOps.makeDouble(supplier, accumulator, operator));
}
项目:Java8CN    文件:ReduceOps.java   
/**
 * Constructs a {@code TerminalOp} that implements a mutable reduce on
 * {@code double} values.
 *
 * @param <R> the type of the result
 * @param supplier a factory to produce a new accumulator of the result type
 * @param accumulator a function to incorporate an int into an
 *        accumulator
 * @param combiner a function to combine an accumulator into another
 * @return a {@code TerminalOp} implementing the reduction
 */
public static <R> TerminalOp<Double, R>
makeDouble(Supplier<R> supplier,
           ObjDoubleConsumer<R> accumulator,
           BinaryOperator<R> combiner) {
    Objects.requireNonNull(supplier);
    Objects.requireNonNull(accumulator);
    Objects.requireNonNull(combiner);
    class ReducingSink extends Box<R>
            implements AccumulatingSink<Double, R, ReducingSink>, Sink.OfDouble {
        @Override
        public void begin(long size) {
            state = supplier.get();
        }

        @Override
        public void accept(double t) {
            accumulator.accept(state, t);
        }

        @Override
        public void combine(ReducingSink other) {
            state = combiner.apply(state, other.state);
        }
    }
    return new ReduceOp<Double, R, ReducingSink>(StreamShape.DOUBLE_VALUE) {
        @Override
        public ReducingSink makeSink() {
            return new ReducingSink();
        }
    };
}
项目:Java8CN    文件:DoublePipeline.java   
@Override
public final <R> R collect(Supplier<R> supplier,
                           ObjDoubleConsumer<R> accumulator,
                           BiConsumer<R, R> combiner) {
    BinaryOperator<R> operator = (left, right) -> {
        combiner.accept(left, right);
        return left;
    };
    return evaluate(ReduceOps.makeDouble(supplier, accumulator, operator));
}
项目:mutable-stream    文件:CollectDoubleTerminatorImpl.java   
public CollectDoubleTerminatorImpl(
        HasNext<Double, DoubleStream> previous, 
        boolean parallel, 
        Supplier<R> supplier, 
        ObjDoubleConsumer<R> accumulator, 
        BiConsumer<R, R> combiner) {

    super(previous, parallel);
    this.supplier    = requireNonNull(supplier);
    this.accumulator = requireNonNull(accumulator);
    this.combiner    = requireNonNull(combiner);
}
项目:mutable-stream    文件:CollectDoubleTerminator.java   
static <R> CollectDoubleTerminator<R> create(
        HasNext<Double, DoubleStream> previous, 
        boolean parallel, 
        Supplier<R> supplier, 
        ObjDoubleConsumer<R> accumulator, 
        BiConsumer<R, R> merger) {

    return new CollectDoubleTerminatorImpl<>(
        previous, parallel, supplier, accumulator, merger
    );
}
项目:jdk8u_jdk    文件:ReduceOps.java   
/**
 * Constructs a {@code TerminalOp} that implements a mutable reduce on
 * {@code double} values.
 *
 * @param <R> the type of the result
 * @param supplier a factory to produce a new accumulator of the result type
 * @param accumulator a function to incorporate an int into an
 *        accumulator
 * @param combiner a function to combine an accumulator into another
 * @return a {@code TerminalOp} implementing the reduction
 */
public static <R> TerminalOp<Double, R>
makeDouble(Supplier<R> supplier,
           ObjDoubleConsumer<R> accumulator,
           BinaryOperator<R> combiner) {
    Objects.requireNonNull(supplier);
    Objects.requireNonNull(accumulator);
    Objects.requireNonNull(combiner);
    class ReducingSink extends Box<R>
            implements AccumulatingSink<Double, R, ReducingSink>, Sink.OfDouble {
        @Override
        public void begin(long size) {
            state = supplier.get();
        }

        @Override
        public void accept(double t) {
            accumulator.accept(state, t);
        }

        @Override
        public void combine(ReducingSink other) {
            state = combiner.apply(state, other.state);
        }
    }
    return new ReduceOp<Double, R, ReducingSink>(StreamShape.DOUBLE_VALUE) {
        @Override
        public ReducingSink makeSink() {
            return new ReducingSink();
        }
    };
}
项目:jdk8u_jdk    文件:DoublePipeline.java   
@Override
public final <R> R collect(Supplier<R> supplier,
                           ObjDoubleConsumer<R> accumulator,
                           BiConsumer<R, R> combiner) {
    BinaryOperator<R> operator = (left, right) -> {
        combiner.accept(left, right);
        return left;
    };
    return evaluate(ReduceOps.makeDouble(supplier, accumulator, operator));
}
项目:lookaside_java-1.8.0-openjdk    文件:ReduceOps.java   
/**
 * Constructs a {@code TerminalOp} that implements a mutable reduce on
 * {@code double} values.
 *
 * @param <R> the type of the result
 * @param supplier a factory to produce a new accumulator of the result type
 * @param accumulator a function to incorporate an int into an
 *        accumulator
 * @param combiner a function to combine an accumulator into another
 * @return a {@code TerminalOp} implementing the reduction
 */
public static <R> TerminalOp<Double, R>
makeDouble(Supplier<R> supplier,
           ObjDoubleConsumer<R> accumulator,
           BinaryOperator<R> combiner) {
    Objects.requireNonNull(supplier);
    Objects.requireNonNull(accumulator);
    Objects.requireNonNull(combiner);
    class ReducingSink extends Box<R>
            implements AccumulatingSink<Double, R, ReducingSink>, Sink.OfDouble {
        @Override
        public void begin(long size) {
            state = supplier.get();
        }

        @Override
        public void accept(double t) {
            accumulator.accept(state, t);
        }

        @Override
        public void combine(ReducingSink other) {
            state = combiner.apply(state, other.state);
        }
    }
    return new ReduceOp<Double, R, ReducingSink>(StreamShape.DOUBLE_VALUE) {
        @Override
        public ReducingSink makeSink() {
            return new ReducingSink();
        }
    };
}
项目:lookaside_java-1.8.0-openjdk    文件:DoublePipeline.java   
@Override
public final <R> R collect(Supplier<R> supplier,
                           ObjDoubleConsumer<R> accumulator,
                           BiConsumer<R, R> combiner) {
    BinaryOperator<R> operator = (left, right) -> {
        combiner.accept(left, right);
        return left;
    };
    return evaluate(ReduceOps.makeDouble(supplier, accumulator, operator));
}
项目:memoization.java    文件:CaffeineMemoizeCustomKeyTest.java   
/**
*
*/
@Test
public void shouldMemoizeObjDoubleConsumerWithKeyFunction() {
    // given
    final ObjDoubleConsumer<Long> consumer = (first, second) -> System.out.println(first.toString() + second);
    final ObjDoubleFunction<Long, String> keyFunction = objDoubleConsumerHashCodeKeyFunction();

    // when
    final ObjDoubleConsumer<Long> memoize = CaffeineMemoize.objDoubleConsumer(consumer, keyFunction);

    // then
    Assert.assertNotNull("Memoized ObjDoubleConsumer is NULL", memoize);
}
项目:memoization.java    文件:CaffeineMemoizeDefaultsTest.java   
/**
*
*/
@Test
public void shouldMemoizeObjDoubleConsumer() {
    // given
    final ObjDoubleConsumer<Long> consumer = (first, second) -> System.out.println(first + " " + second);

    // when
    final ObjDoubleConsumer<Long> memoize = CaffeineMemoize.objDoubleConsumer(consumer);

    // then
    Assert.assertNotNull("Memoized ObjDoubleConsumer is NULL", memoize);
}
项目:memoization.java    文件:CaffeineMemoizeLambdaTest.java   
/**
*
*/
@Test
public void shouldMemoizeObjDoubleConsumerWithLambda() {
    // given

    // when
    final ObjDoubleConsumer<Long> memoize = CaffeineMemoize
            .objDoubleConsumer((first, second) -> System.out.println(first + " " + second));

    // then
    Assert.assertNotNull("Memoized ObjDoubleConsumer is NULL", memoize);
}
项目:memoization.java    文件:GuavaCacheBasedObjDoubleConsumerMemoizer.java   
GuavaCacheBasedObjDoubleConsumerMemoizer(
        final Cache<KEY, KEY> cache,
        final ObjDoubleFunction<FIRST, KEY> keyFunction,
        final ObjDoubleConsumer<FIRST> biConsumer) {
    super(cache);
    this.keyFunction = keyFunction;
    this.biConsumer = biConsumer;
}
项目:memoization.java    文件:GuavaMemoizeCustomKeyTest.java   
/**
*
*/
@Test
public void shouldMemoizeObjDoubleConsumerWithKeyFunction() {
    // given
    final ObjDoubleConsumer<String> consumer = (a, b) -> System.out.println(a + b);
    final ObjDoubleFunction<String, String> keyFunction = (a, b) -> "key";

    // when
    final ObjDoubleConsumer<String> memoize = GuavaMemoize.objDoubleConsumer(consumer, keyFunction);

    // then
    Assert.assertNotNull("Memoized ObjDoubleConsumer is NULL", memoize);
}
项目:memoization.java    文件:GuavaCacheBasedObjDoubleConsumerMemoizerTest.java   
/**
*
*/
@Test
public void shouldAcceptCacheAndKeyFunctionAndBiConsumer() {
    // given
    final ObjDoubleConsumer<String> biConsumer = (first, second) -> System.out.println(first + second);
    final ObjDoubleFunction<String, String> keyFunction = (first, second) -> second + first;
    final Cache<String, String> cache = CacheBuilder.newBuilder().build();

    // when
    final GuavaCacheBasedObjDoubleConsumerMemoizer<String, String> memoizer = new GuavaCacheBasedObjDoubleConsumerMemoizer<>(
            cache, keyFunction, biConsumer);

    // then
    Assert.assertNotNull(memoizer);
}
项目:memoization.java    文件:GuavaMemoizeLambdaTest.java   
/**
*
*/
@Test
public void shouldMemoizeObjDoubleConsumerWithLambda() {
    // given

    // when
    final ObjDoubleConsumer<String> memoize = GuavaMemoize.objDoubleConsumer((a, b) -> System.out.println(a + b));

    // then
    Assert.assertNotNull("Memoized ObjDoubleConsumer is NULL", memoize);
}
项目:memoization.java    文件:GuavaMemoizeDefaultsTest.java   
/**
*
*/
@Test
public void shouldMemoizeObjDoubleConsumer() {
    // given
    final ObjDoubleConsumer<String> consumer = (a, b) -> System.out.println(a + b);

    // when
    final ObjDoubleConsumer<String> memoize = GuavaMemoize.objDoubleConsumer(consumer);

    // then
    Assert.assertNotNull("Memoized ObjDoubleConsumer is NULL", memoize);
}
项目:memoization.java    文件:JCacheBasedObjDoubleConsumerMemoizer.java   
JCacheBasedObjDoubleConsumerMemoizer(
        final Cache<KEY, KEY> cache,
        final ObjDoubleFunction<FIRST, KEY> keyFunction,
        final ObjDoubleConsumer<FIRST> biConsumer) {
    super(cache);
    this.keyFunction = keyFunction;
    this.biConsumer = biConsumer;
}
项目:memoization.java    文件:JCacheBasedObjDoubleConsumerMemoizerTest.java   
/**
*
*/
@Test
public void shouldMemoizeBiConsumer() {
    // given
    final ObjDoubleConsumer<String> biConsumer = (first, second) -> System.out.println(first + second);
    final ObjDoubleFunction<String, String> keyfunction = (a, b) -> "key";
    try (final Cache<String, String> cache = JCacheMemoize.createCache(BiConsumer.class)) {
        // when
        final JCacheBasedObjDoubleConsumerMemoizer<String, String> memoizer = new JCacheBasedObjDoubleConsumerMemoizer<>(
                cache, keyfunction, biConsumer);

        // then
        Assert.assertNotNull("Memoizer is NULL", memoizer);
    }
}
项目:memoization.java    文件:JCacheMemoizeCustomKeyTest.java   
/**
*
*/
@Test
public void shouldMemoizeObjDoubleConsumerWithKeyFunction() {
    // given
    final ObjDoubleConsumer<String> consumer = (a, b) -> System.out.println(a + b);
    final ObjDoubleFunction<String, String> keyFunction = (a, b) -> "key";

    // when
    final ObjDoubleConsumer<String> memoize = JCacheMemoize.objDoubleConsumer(consumer, keyFunction);

    // then
    Assert.assertNotNull("Memoized ObjDoubleConsumer is NULL", memoize);
}
项目:memoization.java    文件:JCacheMemoizeLambdaTest.java   
/**
*
*/
@Test
public void shouldMemoizeObjDoubleConsumerWithLambda() {
    // given

    // when
    final ObjDoubleConsumer<String> memoize = JCacheMemoize.objDoubleConsumer((a, b) -> System.out.println(a + b));

    // then
    Assert.assertNotNull("Memoized ObjDoubleConsumer is NULL", memoize);
}
项目:memoization.java    文件:JCacheMemoizeDefaultsTest.java   
/**
*
*/
@Test
public void shouldMemoizeObjDoubleConsumer() {
    // given
    final ObjDoubleConsumer<String> consumer = (a, b) -> System.out.println(a + b);

    // when
    final ObjDoubleConsumer<String> memoize = JCacheMemoize.objDoubleConsumer(consumer);

    // then
    Assert.assertNotNull("Memoized ObjDoubleConsumer is NULL", memoize);
}
项目:memoization.java    文件:ConcurrentMapBasedObjDoubleConsumerMemoizer.java   
@SuppressWarnings(CompilerWarnings.NLS)
ConcurrentMapBasedObjDoubleConsumerMemoizer(
        final ConcurrentMap<KEY, INPUT> cache,
        final ObjDoubleFunction<INPUT, KEY> keyFunction,
        final ObjDoubleConsumer<INPUT> consumer) {
    super(cache);
    this.keyFunction = requireNonNull(keyFunction,
            "Provide a key function, might just be 'MemoizationDefaults.objDoubleConsumerHashCodeKeyFunction()'.");
    this.consumer = requireNonNull(consumer,
            "Cannot memoize a NULL Consumer - provide an actual Consumer to fix this.");
}
项目:memoization.java    文件:MapMemoizeDefaultsTest.java   
/**
*
*/
@Test
public void shouldMemoizeObjDoubleConsumer() {
    // given
    final ObjDoubleConsumer<String> consumer = (first, second) -> System.out.println(first + second);

    // when
    final ObjDoubleConsumer<String> memoize = MapMemoize.objDoubleConsumer(consumer);

    // then
    Assert.assertNotNull("Memoized ObjDoubleConsumer is NULL", memoize);
}
项目:memoization.java    文件:MapMemoizeLambdaTest.java   
/**
*
*/
@Test
public void shouldMemoizeObjDoubleConsumerWithLambda() {
    // given

    // when
    final ObjDoubleConsumer<String> memoize = MapMemoize
            .objDoubleConsumer((first, second) -> System.out.println(first + second));

    // then
    Assert.assertNotNull("Memoized ObjDoubleConsumer is NULL", memoize);
}