Package org.junit.jupiter.api.function
Interface ThrowingConsumer<T>
-
- Type Parameters:
T- the type of argument consumed
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface @API(status=STABLE, since="5.0") public interface ThrowingConsumer<T>ThrowingConsumeris a functional interface that can be used to implement any generic block of code that consumes an argument and potentially throws aThrowable.The
ThrowingConsumerinterface is similar toConsumer, except that aThrowingConsumercan throw any kind of exception, including checked exceptions.Rationale for throwing
Throwableinstead ofExceptionAlthough Java applications typically throw exceptions that are instances of
Exception,RuntimeException,Error, orAssertionError(in testing scenarios), there may be use cases where aThrowingConsumerneeds to explicitly throw aThrowable. In order to support such specialized use cases,accept(T)is declared to throwThrowable.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaccept(T t)Consume the supplied argument, potentially throwing an exception.
-
-
-
Method Detail
-
accept
void accept(T t) throws java.lang.Throwable
Consume the supplied argument, potentially throwing an exception.- Parameters:
t- the argument to consume- Throws:
java.lang.Throwable
-
-