- Type Parameters:
T- the type of argument supplied
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
ThrowingSupplieris a functional interface that can be used to implement any generic block of code that returns an object and potentially throws a
ThrowingSupplierinterface is similar to
Supplier, except that a
ThrowingSuppliercan throw any kind of exception, including checked exceptions.
Rationale for throwing
Although Java applications typically throw exceptions that are instances of
AssertionError(in testing scenarios), there may be use cases where a
ThrowingSupplierneeds to explicitly throw a
Throwable. In order to support such specialized use cases,
get()is declared to throw
T get() throws java.lang.ThrowableGet a result, potentially throwing an exception.
- a result