T - the type of the input to the operationX - the type of the exception that can be thrown by this operation@FunctionalInterface public interface ThrowingConsumer<T,X extends Exception>
X. Unlike most other functional interfaces,
ThrowingConsumer is expected to operate via side-effects and may throw exceptions during execution.
This is a functional interface whose functional method is accept(Object).
| Modifier and Type | Method and Description |
|---|---|
void |
accept(T t)
Performs this operation on the given argument.
|
static <T> @NotNull Consumer<T> |
of(@NotNull ThrowingConsumer<T,?> throwingConsumer)
Creates and returns a new Consumer that will wrap any exceptions thrown by the
provided
throwingConsumer in a ThrowingConsumerException. |
@NotNull static <T> @NotNull Consumer<T> of(@NotNull @NotNull ThrowingConsumer<T,?> throwingConsumer)
throwingConsumer in a ThrowingConsumerException.
This method allows the integration of a ThrowingConsumer into contexts where a regular Consumer is expected, by translating checked exceptions into runtime exceptions.
T - consumed typethrowingConsumer - the ThrowingConsumer to wrap, must not be nullNullPointerException - if throwingConsumer is nullCopyright © 2024. All rights reserved.