T
- The type of the first input to the operation.U
- The type of the second input to the operation.E
- The type of the exception that can be thrown.@FunctionalInterface public interface ThrowingBiConsumer<T,U,E extends Exception> extends BiConsumer<T,U>
BiConsumer
is
expected to operate via side-effects.
The ThrowingBiConsumer
distinguishes itself from BiConsumer
by allowing the functional interface to throw an Exception
. This can
be used to allow lambda expressions to propagate checked exceptions up the
expression's call stack. An example of this pattern:
BiConsumer<Integer,Integer> consumer = Throwing.<Integer,Integer>rethrow((i, j) -> {
if (i == 0)
throw new IllegalArgumentException("i=" + i);
});
for (int i = 3; i >= 0; --i)
consumer.accept(i, -i);
Throwing
Modifier and Type | Method and Description |
---|---|
default void |
accept(T t,
U u) |
void |
acceptThrows(T t,
U u)
Performs this operation on the given argument, allowing an exception to be
thrown.
|
andThen
Copyright © 2020 LibJ. All rights reserved.