Interface BiConsumer<T,U>
- Type Parameters:
T- the first parameter typeU- the second parameter type
- All Superinterfaces:
BiConsumer<T,U>
An enhanced binary consumer.
- Author:
- Paul Ferraro
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic <T,U> BiConsumer <T, U> acceptAll(Iterable<? extends BiConsumer<? super T, ? super U>> consumers) Returns a composite consumer that delegates to zero or more consumers.static <T,U> BiConsumer <T, U> acceptFormer(Consumer<? super T> consumer) Returns a consumer that delegates to a consumer of the first parameter, ignoring the second.static <T,U> BiConsumer <T, U> acceptLatter(Consumer<? super U> consumer) Returns a consumer that delegates to a consumer of the second parameter, ignoring the first.default BiConsumer<T, U> andThen(BiConsumer<? super T, ? super U> after) default <V1,V2> BiConsumer <V1, V2> Composes a binary consumer using the specified parameter mapping functions.default <V> Consumer<V> composeUnary(Function<? super V, T> mapper1, Function<? super V, U> mapper2) Composes a unary consumer using the specified parameter mapping functions.static <T,U> BiConsumer <T, U> empty()Returns a consumer that performs no action.default BiConsumer<T, U> handle(Consumer<RuntimeException> handler) Returns a new consumer that delegates to the specified handler in the event of an exception.static <T,U> BiConsumer <T, U> Returns a composite consumer that delegates to a consumer per parameter.default BiConsumer<U, T> reverse()Returns a consumer that processes this consumer with reversed parameter order.default <R> BiFunction<T, U, R> thenReturn(Supplier<R> factory) Returns a function that returns the value from the specified supplier after accepting its parameters via this consumer.static <E extends Throwable>
BiConsumer<String, E> throwing(BiFunction<String, E, ? extends RuntimeException> exceptionFactory) Returns a consumer that wraps an exception as a runtime exception via the specified factory.Methods inherited from interface BiConsumer
accept
-
Field Details
-
EMPTY
An empty consumer
-
-
Method Details
-
andThen
- Specified by:
andThenin interfaceBiConsumer<T,U>
-
compose
default <V1,V2> BiConsumer<V1,V2> compose(Function<? super V1, T> mapper1, Function<? super V2, U> mapper2) Composes a binary consumer using the specified parameter mapping functions.- Type Parameters:
V1- the former mapped typeV2- the latter mapped type- Parameters:
mapper1- a mapping function for the former parametermapper2- a mapping function for the latter parameter- Returns:
- a mapped consumer
-
composeUnary
default <V> Consumer<V> composeUnary(Function<? super V, T> mapper1, Function<? super V, U> mapper2) Composes a unary consumer using the specified parameter mapping functions.- Type Parameters:
V- the mapped type- Parameters:
mapper1- a mapping function for the former parametermapper2- a mapping function for the latter parameter- Returns:
- a mapped consumer
-
reverse
Returns a consumer that processes this consumer with reversed parameter order.- Returns:
- a consumer that processes this consumer with reversed parameter order.
-
handle
Returns a new consumer that delegates to the specified handler in the event of an exception.- Parameters:
handler- an exception handler- Returns:
- a new consumer that delegates to the specified handler in the event of an exception.
-
thenReturn
Returns a function that returns the value from the specified supplier after accepting its parameters via this consumer.- Type Parameters:
R- the supplied type- Parameters:
factory- a factory of the function return value- Returns:
- a function that returns the value from the specified supplier after accepting its parameters via this consumer.
-
empty
Returns a consumer that performs no action.- Type Parameters:
T- the first consumed typeU- the second consumed type- Returns:
- an empty consumer
-
acceptFormer
Returns a consumer that delegates to a consumer of the first parameter, ignoring the second.- Type Parameters:
T- the first consumed typeU- the second consumed type- Parameters:
consumer- the consumer of the first parameter- Returns:
- a consumer of the first parameter
-
acceptLatter
Returns a consumer that delegates to a consumer of the second parameter, ignoring the first.- Type Parameters:
T- the first consumed typeU- the second consumed type- Parameters:
consumer- the consumer of the second parameter- Returns:
- a consumer that delegates to a consumer of the second parameter, ignoring the first.
-
of
Returns a composite consumer that delegates to a consumer per parameter.- Type Parameters:
T- the first consumed typeU- the second consumed type- Parameters:
consumer1- the consumer of the first parameterconsumer2- the consumer of the second parameter- Returns:
- a composite consumer
-
acceptAll
static <T,U> BiConsumer<T,U> acceptAll(Iterable<? extends BiConsumer<? super T, ? super U>> consumers) Returns a composite consumer that delegates to zero or more consumers.- Type Parameters:
T- the first consumed typeU- the second consumed type- Parameters:
consumers- zero or more consumers- Returns:
- a composite consumer
-
throwing
static <E extends Throwable> BiConsumer<String,E> throwing(BiFunction<String, E, ? extends RuntimeException> exceptionFactory) Returns a consumer that wraps an exception as a runtime exception via the specified factory.- Type Parameters:
E- the exception type- Parameters:
exceptionFactory- a runtime exception wrapper- Returns:
- a consumer that wraps an exception as a runtime exception via the specified factory.
-