ThrowingConsumer is a functional interface that can be used to
implement any generic block of code that consumes an argument and
potentially throws a Throwable.
The ThrowingConsumer interface is similar to
java., except that a ThrowingConsumer
can throw any kind of exception, including checked exceptions.
Throwable instead of ExceptionAlthough Java applications typically throw exceptions that are instances
of java., java.,
java., or java. (in testing
scenarios), there may be use cases where a ThrowingConsumer needs to
explicitly throw a Throwable. In order to support such specialized
use cases, accept is declared to throw Throwable.
java.util.function.Consumer , org.junit.jupiter.api.DynamicTest#stream , Executable, ThrowingSupplier
| Modifier and Type | Method and Description |
|---|---|
| public void |
| accept | back to summary |
|---|---|
| public void accept(T t) throws Throwable Consume the supplied argument, potentially throwing an exception.
| |