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

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

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

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

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

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

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

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

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

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

    // then
    memoizer.accept("test", 123);
    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    文件:ConcurrentMapBasedObjIntConsumerMemoizerTest.java   
/**
*
*/
@Test
@SuppressWarnings(CompilerWarnings.UNCHECKED)
public void shouldUseCallWrappedConsumer() {
    // given
    final ConcurrentMap<String, String> cache = new ConcurrentHashMap<>();
    final ObjIntFunction<String, String> keyFunction = (first, second) -> first + second;
    final ObjIntConsumer<String> consumer = Mockito.mock(ObjIntConsumer.class);

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

    // then
    memoizer.accept("test", 123);
    Mockito.verify(consumer).accept("test", 123);
}
项目:peppol-directory    文件:PDStorageManager.java   
@Nonnull
@ReturnsMutableCopy
public ICommonsSortedSet <IParticipantIdentifier> getAllContainedParticipantIDs ()
{
  final ICommonsSortedSet <IParticipantIdentifier> aTargetSet = new CommonsTreeSet <> ();
  final Query aQuery = PDQueryManager.andNotDeleted (new MatchAllDocsQuery ());
  try
  {
    final ObjIntConsumer <Document> aConsumer = (aDoc,
                                                 nDocID) -> aTargetSet.add (PDField.PARTICIPANT_ID.getDocValue (aDoc));
    final Collector aCollector = new AllDocumentsCollector (m_aLucene, aConsumer);
    searchAtomic (aQuery, aCollector);
  }
  catch (final IOException ex)
  {
    s_aLogger.error ("Error searching for documents with query " + aQuery, ex);
  }
  return aTargetSet;
}
项目:ph-commons    文件:StreamHelper.java   
public static void readUntilEOF (@Nonnull @WillClose final InputStream aIS,
                                 @Nonnull final byte [] aBuffer,
                                 @Nonnull final ObjIntConsumer <? super byte []> aConsumer) throws IOException
{
  try
  {
    ValueEnforcer.notNull (aIS, "InputStream");
    ValueEnforcer.notNull (aBuffer, "Buffer");
    ValueEnforcer.notNull (aConsumer, "Consumer");

    _readUntilEOF (aIS, aBuffer, aConsumer);
  }
  finally
  {
    close (aIS);
  }
}
项目:ph-commons    文件:StreamHelper.java   
public static void readUntilEOF (@Nonnull @WillClose final Reader aReader,
                                 @Nonnull final char [] aBuffer,
                                 @Nonnull final ObjIntConsumer <? super char []> aConsumer) throws IOException
{
  try
  {
    ValueEnforcer.notNull (aReader, "Reader");
    ValueEnforcer.notNull (aBuffer, "Buffer");
    ValueEnforcer.notNull (aConsumer, "Consumer");

    _readUntilEOF (aReader, aBuffer, aConsumer);
  }
  finally
  {
    close (aReader);
  }
}
项目:jOOL    文件:CheckedBiConsumerTest.java   
@Test
public void testCheckedObjIntConsumer() {
    final CheckedObjIntConsumer<Object> objIntConsumer = (o1, o2) -> {
        throw new Exception(o1 + ":" + o2);
    };

    ObjIntConsumer<Object> c1 = Unchecked.objIntConsumer(objIntConsumer);
    ObjIntConsumer<Object> c2 = CheckedObjIntConsumer.unchecked(objIntConsumer);
    ObjIntConsumer<Object> c3 = Sneaky.objIntConsumer(objIntConsumer);
    ObjIntConsumer<Object> c4 = CheckedObjIntConsumer.sneaky(objIntConsumer);

    assertObjIntConsumer(c1, UncheckedException.class);
    assertObjIntConsumer(c2, UncheckedException.class);
    assertObjIntConsumer(c3, Exception.class);
    assertObjIntConsumer(c4, Exception.class);
}
项目:elasticsearch_my    文件:Augmentation.java   
/** 
 * Iterates through an iterable type, passing each item and the item's index 
 * (a counter starting at zero) to the given consumer.
 */
public static <T> Object eachWithIndex(Iterable<T> receiver, ObjIntConsumer<T> consumer) {
    int count = 0;
    for (T t : receiver) {
        consumer.accept(t, count++);
    }
    return receiver;
}
项目:guava-mock    文件:RegularImmutableSortedMultiset.java   
@Override
public void forEachEntry(ObjIntConsumer<? super E> action) {
  checkNotNull(action);
  for (int i = 0; i < length; i++) {
    action.accept(elementSet.asList().get(i), getCount(i));
  }
}
项目:OpenJSharp    文件:ReduceOps.java   
/**
 * Constructs a {@code TerminalOp} that implements a mutable reduce on
 * {@code int} 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 ReduceOp} implementing the reduction
 */
public static <R> TerminalOp<Integer, R>
makeInt(Supplier<R> supplier,
        ObjIntConsumer<R> accumulator,
        BinaryOperator<R> combiner) {
    Objects.requireNonNull(supplier);
    Objects.requireNonNull(accumulator);
    Objects.requireNonNull(combiner);
    class ReducingSink extends Box<R>
            implements AccumulatingSink<Integer, R, ReducingSink>, Sink.OfInt {
        @Override
        public void begin(long size) {
            state = supplier.get();
        }

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

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

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

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

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

        @Override
        public void combine(ReducingSink other) {
            state = combiner.apply(state, other.state);
        }
    }
    return new ReduceOp<Integer, R, ReducingSink>(StreamShape.INT_VALUE) {
        @Override
        public ReducingSink makeSink() {
            return new ReducingSink();
        }
    };
}
项目:openjdk-jdk10    文件:IntPipeline.java   
@Override
public final <R> R collect(Supplier<R> supplier,
                           ObjIntConsumer<R> accumulator,
                           BiConsumer<R, R> combiner) {
    Objects.requireNonNull(combiner);
    BinaryOperator<R> operator = (left, right) -> {
        combiner.accept(left, right);
        return left;
    };
    return evaluate(ReduceOps.makeInt(supplier, accumulator, operator));
}
项目:googles-monorepo-demo    文件:RegularImmutableSortedMultiset.java   
@Override
public void forEachEntry(ObjIntConsumer<? super E> action) {
  checkNotNull(action);
  for (int i = 0; i < size(); i++) {
    action.accept(elementSet.asList().get(i), getCount(i));
  }
}
项目:openjdk9    文件:ReduceOps.java   
/**
 * Constructs a {@code TerminalOp} that implements a mutable reduce on
 * {@code int} 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 ReduceOp} implementing the reduction
 */
public static <R> TerminalOp<Integer, R>
makeInt(Supplier<R> supplier,
        ObjIntConsumer<R> accumulator,
        BinaryOperator<R> combiner) {
    Objects.requireNonNull(supplier);
    Objects.requireNonNull(accumulator);
    Objects.requireNonNull(combiner);
    class ReducingSink extends Box<R>
            implements AccumulatingSink<Integer, R, ReducingSink>, Sink.OfInt {
        @Override
        public void begin(long size) {
            state = supplier.get();
        }

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

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

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

        @Override
        public void combine(ReducingSink other) {
            state = combiner.apply(state, other.state);
        }
    }
    return new ReduceOp<Integer, R, ReducingSink>(StreamShape.INT_VALUE) {
        @Override
        public ReducingSink makeSink() {
            return new ReducingSink();
        }
    };
}
项目:Java8CN    文件:IntPipeline.java   
@Override
public final <R> R collect(Supplier<R> supplier,
                           ObjIntConsumer<R> accumulator,
                           BiConsumer<R, R> combiner) {
    BinaryOperator<R> operator = (left, right) -> {
        combiner.accept(left, right);
        return left;
    };
    return evaluate(ReduceOps.makeInt(supplier, accumulator, operator));
}
项目:judge    文件:ContestService.java   
@SuppressWarnings("ValueOfIncrementOrDecrementUsed")
private <T> void setIndexes(T[] standings, Comparator<T> c, ObjIntConsumer<T> consumer) {
    Objects.requireNonNull(standings, "standings");
    Objects.requireNonNull(c, "c");
    Objects.requireNonNull(consumer, "consumer");
    int i = 0, len = standings.length, lastIndex = 0;

    for (T last = null, standing; i < len; last = standing) {
        standing = standings[i++];
        if (c.compare(standing, last) != 0) {
            lastIndex = i;
        }
        consumer.accept(standing, lastIndex);
    }
}
项目:mutable-stream    文件:CollectIntTerminatorImpl.java   
public CollectIntTerminatorImpl(
        HasNext<Integer, IntStream> previous, 
        boolean parallel, 
        Supplier<R> supplier, 
        ObjIntConsumer<R> accumulator, 
        BiConsumer<R, R> combiner) {

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

    return new CollectIntTerminatorImpl<>(
        previous, parallel, supplier, accumulator, merger
    );
}
项目:jdk8u_jdk    文件:ReduceOps.java   
/**
 * Constructs a {@code TerminalOp} that implements a mutable reduce on
 * {@code int} 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 ReduceOp} implementing the reduction
 */
public static <R> TerminalOp<Integer, R>
makeInt(Supplier<R> supplier,
        ObjIntConsumer<R> accumulator,
        BinaryOperator<R> combiner) {
    Objects.requireNonNull(supplier);
    Objects.requireNonNull(accumulator);
    Objects.requireNonNull(combiner);
    class ReducingSink extends Box<R>
            implements AccumulatingSink<Integer, R, ReducingSink>, Sink.OfInt {
        @Override
        public void begin(long size) {
            state = supplier.get();
        }

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

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

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

        @Override
        public void combine(ReducingSink other) {
            state = combiner.apply(state, other.state);
        }
    }
    return new ReduceOp<Integer, R, ReducingSink>(StreamShape.INT_VALUE) {
        @Override
        public ReducingSink makeSink() {
            return new ReducingSink();
        }
    };
}
项目:lookaside_java-1.8.0-openjdk    文件:IntPipeline.java   
@Override
public final <R> R collect(Supplier<R> supplier,
                           ObjIntConsumer<R> accumulator,
                           BiConsumer<R, R> combiner) {
    BinaryOperator<R> operator = (left, right) -> {
        combiner.accept(left, right);
        return left;
    };
    return evaluate(ReduceOps.makeInt(supplier, accumulator, operator));
}
项目:memoization.java    文件:CaffeineMemoizeCustomKeyTest.java   
/**
*
*/
@Test
public void shouldMemoizeObjIntConsumerWithKeyFunction() {
    // given
    final ObjIntConsumer<Long> consumer = (first, second) -> System.out.println(first.toString() + second);
    final ObjIntFunction<Long, String> keyFunction = MemoizationDefaults.objIntConsumerHashCodeKeyFunction();

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

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

    // when
    final ObjIntConsumer<Long> memoize = CaffeineMemoize.objIntConsumer(consumer);

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

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

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

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

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

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

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

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

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

    // when
    final ObjIntConsumer<String> memoize = GuavaMemoize.objIntConsumer(consumer);

    // then
    Assert.assertNotNull("Memoized ObjIntConsumer is NULL", memoize);
}
项目:memoization.java    文件:JCacheBasedObjIntConsumerMemoizer.java   
JCacheBasedObjIntConsumerMemoizer(
        final Cache<KEY, KEY> cache,
        final ObjIntFunction<FIRST, KEY> keyFunction,
        final ObjIntConsumer<FIRST> biConsumer) {
    super(cache);
    this.keyFunction = keyFunction;
    this.biConsumer = biConsumer;
}