예제 #1
0
 /**
  * Returns a composed {@link TriLongConsumer} that first applies the {@code before} functions to
  * its input, and then applies this consumer to the result. If evaluation of either operation
  * throws an exception, it is relayed to the caller of the composed operation. This method is just
  * convenience, to provide the ability to execute an operation which accepts {@code long} input,
  * before this primitive consumer is executed.
  *
  * @param before1 The first function to apply before this consumer is applied
  * @param before2 The second function to apply before this consumer is applied
  * @param before3 The third function to apply before this consumer is applied
  * @return A composed {@code TriLongConsumer} that first applies the {@code before} functions to
  *     its input, and then applies this consumer to the result.
  * @throws NullPointerException If given argument is {@code null}
  * @implSpec The input argument of this method is a able to handle primitive values. In this case
  *     this is {@code long}.
  */
 @Nonnull
 default TriLongConsumer composeFromLong(
     @Nonnull final LongFunction<? extends T> before1,
     @Nonnull final LongToIntFunction before2,
     @Nonnull final LongToIntFunction before3) {
   Objects.requireNonNull(before1);
   Objects.requireNonNull(before2);
   Objects.requireNonNull(before3);
   return (value1, value2, value3) ->
       accept(before1.apply(value1), before2.applyAsInt(value2), before3.applyAsInt(value3));
 }
예제 #2
0
  private <E extends RuntimeException> void assertLongToIntFunction(
      LongToIntFunction test, Class<E> type) {
    assertNotNull(test);
    try {
      test.applyAsInt(0L);
      fail();
    } catch (RuntimeException e) {
      assertException(type, e, "0");
    }

    try {
      LongStream.of(1L, 2L, 3L).mapToInt(test);
    } catch (RuntimeException e) {
      assertException(type, e, "1");
    }
  }