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

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

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

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

        // then
        memoizer.accept("first", 123);
        Mockito.verify(biConsumer).accept("first", 123);
    }
}
项目:memoization.java    文件:ConcurrentMapBasedObjLongConsumerMemoizerTest.java   
/**
*
*/
@Test
@SuppressWarnings(CompilerWarnings.UNUSED)
public void shouldRequireNonNullCache() {
    // given
    final ConcurrentMap<String, String> cache = null;
    final ObjLongFunction<String, String> keyFunction = (first, second) -> first + second;
    final ObjLongConsumer<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 ConcurrentMapBasedObjLongConsumerMemoizer<>(cache, keyFunction, consumer);
}
项目:memoization.java    文件:ConcurrentMapBasedObjLongConsumerMemoizerTest.java   
/**
*
*/
@Test
@SuppressWarnings(CompilerWarnings.UNUSED)
public void shouldRequireNonNullKeyFunction() {
    // given
    final ConcurrentMap<String, String> cache = new ConcurrentHashMap<>();
    final ObjLongFunction<String, String> keyFunction = null;
    final ObjLongConsumer<String> consumer = (first, second) -> System.out.println(first + second);

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

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

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

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

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

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

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

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

    ObjLongConsumer<Object> c1 = Unchecked.objLongConsumer(objLongConsumer);
    ObjLongConsumer<Object> c2 = CheckedObjLongConsumer.unchecked(objLongConsumer);
    ObjLongConsumer<Object> c3 = Sneaky.objLongConsumer(objLongConsumer);
    ObjLongConsumer<Object> c4 = CheckedObjLongConsumer.sneaky(objLongConsumer);

    assertObjLongConsumer(c1, UncheckedException.class);
    assertObjLongConsumer(c2, UncheckedException.class);
    assertObjLongConsumer(c3, Exception.class);
    assertObjLongConsumer(c4, Exception.class);
}
项目:OpenJSharp    文件:ReduceOps.java   
/**
 * Constructs a {@code TerminalOp} that implements a mutable reduce on
 * {@code long} 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<Long, R>
makeLong(Supplier<R> supplier,
         ObjLongConsumer<R> accumulator,
         BinaryOperator<R> combiner) {
    Objects.requireNonNull(supplier);
    Objects.requireNonNull(accumulator);
    Objects.requireNonNull(combiner);
    class ReducingSink extends Box<R>
            implements AccumulatingSink<Long, R, ReducingSink>, Sink.OfLong {
        @Override
        public void begin(long size) {
            state = supplier.get();
        }

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

        @Override
        public void combine(ReducingSink other) {
            state = combiner.apply(state, other.state);
        }
    }
    return new ReduceOp<Long, R, ReducingSink>(StreamShape.LONG_VALUE) {
        @Override
        public ReducingSink makeSink() {
            return new ReducingSink();
        }
    };
}
项目:OpenJSharp    文件:LongPipeline.java   
@Override
public final <R> R collect(Supplier<R> supplier,
                           ObjLongConsumer<R> accumulator,
                           BiConsumer<R, R> combiner) {
    BinaryOperator<R> operator = (left, right) -> {
        combiner.accept(left, right);
        return left;
    };
    return evaluate(ReduceOps.makeLong(supplier, accumulator, operator));
}
项目:jdk8u-jdk    文件:ReduceOps.java   
/**
 * Constructs a {@code TerminalOp} that implements a mutable reduce on
 * {@code long} 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<Long, R>
makeLong(Supplier<R> supplier,
         ObjLongConsumer<R> accumulator,
         BinaryOperator<R> combiner) {
    Objects.requireNonNull(supplier);
    Objects.requireNonNull(accumulator);
    Objects.requireNonNull(combiner);
    class ReducingSink extends Box<R>
            implements AccumulatingSink<Long, R, ReducingSink>, Sink.OfLong {
        @Override
        public void begin(long size) {
            state = supplier.get();
        }

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

        @Override
        public void combine(ReducingSink other) {
            state = combiner.apply(state, other.state);
        }
    }
    return new ReduceOp<Long, R, ReducingSink>(StreamShape.LONG_VALUE) {
        @Override
        public ReducingSink makeSink() {
            return new ReducingSink();
        }
    };
}
项目:jdk8u-jdk    文件:LongPipeline.java   
@Override
public final <R> R collect(Supplier<R> supplier,
                           ObjLongConsumer<R> accumulator,
                           BiConsumer<R, R> combiner) {
    BinaryOperator<R> operator = (left, right) -> {
        combiner.accept(left, right);
        return left;
    };
    return evaluate(ReduceOps.makeLong(supplier, accumulator, operator));
}
项目:openjdk-jdk10    文件:ReduceOps.java   
/**
 * Constructs a {@code TerminalOp} that implements a mutable reduce on
 * {@code long} 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<Long, R>
makeLong(Supplier<R> supplier,
         ObjLongConsumer<R> accumulator,
         BinaryOperator<R> combiner) {
    Objects.requireNonNull(supplier);
    Objects.requireNonNull(accumulator);
    Objects.requireNonNull(combiner);
    class ReducingSink extends Box<R>
            implements AccumulatingSink<Long, R, ReducingSink>, Sink.OfLong {
        @Override
        public void begin(long size) {
            state = supplier.get();
        }

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

        @Override
        public void combine(ReducingSink other) {
            state = combiner.apply(state, other.state);
        }
    }
    return new ReduceOp<Long, R, ReducingSink>(StreamShape.LONG_VALUE) {
        @Override
        public ReducingSink makeSink() {
            return new ReducingSink();
        }
    };
}
项目:openjdk-jdk10    文件:LongPipeline.java   
@Override
public final <R> R collect(Supplier<R> supplier,
                           ObjLongConsumer<R> accumulator,
                           BiConsumer<R, R> combiner) {
    Objects.requireNonNull(combiner);
    BinaryOperator<R> operator = (left, right) -> {
        combiner.accept(left, right);
        return left;
    };
    return evaluate(ReduceOps.makeLong(supplier, accumulator, operator));
}
项目:openjdk9    文件:ReduceOps.java   
/**
 * Constructs a {@code TerminalOp} that implements a mutable reduce on
 * {@code long} 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<Long, R>
makeLong(Supplier<R> supplier,
         ObjLongConsumer<R> accumulator,
         BinaryOperator<R> combiner) {
    Objects.requireNonNull(supplier);
    Objects.requireNonNull(accumulator);
    Objects.requireNonNull(combiner);
    class ReducingSink extends Box<R>
            implements AccumulatingSink<Long, R, ReducingSink>, Sink.OfLong {
        @Override
        public void begin(long size) {
            state = supplier.get();
        }

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

        @Override
        public void combine(ReducingSink other) {
            state = combiner.apply(state, other.state);
        }
    }
    return new ReduceOp<Long, R, ReducingSink>(StreamShape.LONG_VALUE) {
        @Override
        public ReducingSink makeSink() {
            return new ReducingSink();
        }
    };
}
项目:openjdk9    文件:LongPipeline.java   
@Override
public final <R> R collect(Supplier<R> supplier,
                           ObjLongConsumer<R> accumulator,
                           BiConsumer<R, R> combiner) {
    Objects.requireNonNull(combiner);
    BinaryOperator<R> operator = (left, right) -> {
        combiner.accept(left, right);
        return left;
    };
    return evaluate(ReduceOps.makeLong(supplier, accumulator, operator));
}
项目:Java8CN    文件:ReduceOps.java   
/**
 * Constructs a {@code TerminalOp} that implements a mutable reduce on
 * {@code long} 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<Long, R>
makeLong(Supplier<R> supplier,
         ObjLongConsumer<R> accumulator,
         BinaryOperator<R> combiner) {
    Objects.requireNonNull(supplier);
    Objects.requireNonNull(accumulator);
    Objects.requireNonNull(combiner);
    class ReducingSink extends Box<R>
            implements AccumulatingSink<Long, R, ReducingSink>, Sink.OfLong {
        @Override
        public void begin(long size) {
            state = supplier.get();
        }

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

        @Override
        public void combine(ReducingSink other) {
            state = combiner.apply(state, other.state);
        }
    }
    return new ReduceOp<Long, R, ReducingSink>(StreamShape.LONG_VALUE) {
        @Override
        public ReducingSink makeSink() {
            return new ReducingSink();
        }
    };
}
项目:Java8CN    文件:LongPipeline.java   
@Override
public final <R> R collect(Supplier<R> supplier,
                           ObjLongConsumer<R> accumulator,
                           BiConsumer<R, R> combiner) {
    BinaryOperator<R> operator = (left, right) -> {
        combiner.accept(left, right);
        return left;
    };
    return evaluate(ReduceOps.makeLong(supplier, accumulator, operator));
}
项目:mutable-stream    文件:CollectLongTerminatorImpl.java   
public CollectLongTerminatorImpl(
        HasNext<Long, LongStream> previous, 
        boolean parallel, 
        Supplier<R> supplier, 
        ObjLongConsumer<R> accumulator, 
        BiConsumer<R, R> combiner) {

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

    return new CollectLongTerminatorImpl<>(
        previous, parallel, supplier, accumulator, merger
    );
}
项目:jdk8u_jdk    文件:ReduceOps.java   
/**
 * Constructs a {@code TerminalOp} that implements a mutable reduce on
 * {@code long} 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<Long, R>
makeLong(Supplier<R> supplier,
         ObjLongConsumer<R> accumulator,
         BinaryOperator<R> combiner) {
    Objects.requireNonNull(supplier);
    Objects.requireNonNull(accumulator);
    Objects.requireNonNull(combiner);
    class ReducingSink extends Box<R>
            implements AccumulatingSink<Long, R, ReducingSink>, Sink.OfLong {
        @Override
        public void begin(long size) {
            state = supplier.get();
        }

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

        @Override
        public void combine(ReducingSink other) {
            state = combiner.apply(state, other.state);
        }
    }
    return new ReduceOp<Long, R, ReducingSink>(StreamShape.LONG_VALUE) {
        @Override
        public ReducingSink makeSink() {
            return new ReducingSink();
        }
    };
}
项目:jdk8u_jdk    文件:LongPipeline.java   
@Override
public final <R> R collect(Supplier<R> supplier,
                           ObjLongConsumer<R> accumulator,
                           BiConsumer<R, R> combiner) {
    BinaryOperator<R> operator = (left, right) -> {
        combiner.accept(left, right);
        return left;
    };
    return evaluate(ReduceOps.makeLong(supplier, accumulator, operator));
}
项目:lookaside_java-1.8.0-openjdk    文件:ReduceOps.java   
/**
 * Constructs a {@code TerminalOp} that implements a mutable reduce on
 * {@code long} 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<Long, R>
makeLong(Supplier<R> supplier,
         ObjLongConsumer<R> accumulator,
         BinaryOperator<R> combiner) {
    Objects.requireNonNull(supplier);
    Objects.requireNonNull(accumulator);
    Objects.requireNonNull(combiner);
    class ReducingSink extends Box<R>
            implements AccumulatingSink<Long, R, ReducingSink>, Sink.OfLong {
        @Override
        public void begin(long size) {
            state = supplier.get();
        }

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

        @Override
        public void combine(ReducingSink other) {
            state = combiner.apply(state, other.state);
        }
    }
    return new ReduceOp<Long, R, ReducingSink>(StreamShape.LONG_VALUE) {
        @Override
        public ReducingSink makeSink() {
            return new ReducingSink();
        }
    };
}
项目:lookaside_java-1.8.0-openjdk    文件:LongPipeline.java   
@Override
public final <R> R collect(Supplier<R> supplier,
                           ObjLongConsumer<R> accumulator,
                           BiConsumer<R, R> combiner) {
    BinaryOperator<R> operator = (left, right) -> {
        combiner.accept(left, right);
        return left;
    };
    return evaluate(ReduceOps.makeLong(supplier, accumulator, operator));
}
项目:memoization.java    文件:CaffeineMemoizeCustomKeyTest.java   
/**
*
*/
@Test
public void shouldMemoizeObjLongConsumerWithKeyFunction() {
    // given
    final ObjLongConsumer<Long> function = (first, second) -> System.out.println(first.toString() + second);
    final ObjLongFunction<Long, String> keyFunction = MemoizationDefaults.objLongConsumerHashCodeKeyFunction();

    // when
    final ObjLongConsumer<Long> memoize = CaffeineMemoize.objLongConsumer(function, keyFunction);

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

    // when
    final ObjLongConsumer<Long> memoize = CaffeineMemoize.objLongConsumer(function);

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

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

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

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

    // then
    Assert.assertNotNull(memoizer);
}
项目:memoization.java    文件:GuavaMemoizeCustomKeyTest.java   
/**
*
*/
@Test
public void shouldMemoizeObjLongConsumerWithKeyFunction() {
    // given
    final ObjLongConsumer<String> consumer = (a, b) -> System.out.println(a + b);
    final ObjLongFunction<String, String> keyFunction = (a, b) -> "key";

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

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

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

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

    // when
    final ObjLongConsumer<String> memoize = GuavaMemoize.objLongConsumer(consumer);

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

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

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

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

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

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

    // when
    final ObjLongConsumer<String> memoize = JCacheMemoize.objLongConsumer(consumer);

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

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

    // then
    Assert.assertNotNull("Memoizer is NULL", memoizer);
}
项目:memoization.java    文件:ConcurrentMapBasedObjLongConsumerMemoizerTest.java   
/**
*
*/
@Test
public void shouldMemoizeConsumer() {
    // given
    final ConcurrentMap<String, String> cache = new ConcurrentHashMap<>();
    final ObjLongFunction<String, String> keyFunction = (first, second) -> first + second;
    final ObjLongConsumer<String> consumer = (first, second) -> System.out.println(first + second);

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

    // then
    memoizer.accept("test", 123);
}