Top Description Methods
org.junit.jupiter.api.function

public Interface ThrowingSupplier<T extends @Nullable Object>

Annotations
@FunctionalInterface
@API
status:STABLE
since:5.0
Type Parameters
<T>
the type of argument supplied
Static Imports
org.apiguardian.api.API.Status.STABLE

ThrowingSupplier is a functional interface that can be used to implement any generic block of code that returns an object and potentially throws a Throwable.

The ThrowingSupplier interface is similar to java.util.function.Supplier, except that a ThrowingSupplier can throw any kind of exception, including checked exceptions.

Rationale for throwing Throwable instead of Exception

Although Java applications typically throw exceptions that are instances of Exception, RuntimeException, Error, or AssertionError (in testing scenarios), there may be use cases where a ThrowingSupplier needs to explicitly throw a Throwable. In order to support such specialized use cases, get is declared to throw Throwable.

Since
5.0
See Also
java.util.function.Supplier, org.junit.jupiter.api.Assertions#assertTimeout(java.time.Duration, ThrowingSupplier), org.junit.jupiter.api.Assertions#assertTimeoutPreemptively(java.time.Duration, ThrowingSupplier), Executable, ThrowingConsumer

Method Summary

Modifier and TypeMethod and Description
public T

Returns:

a result
get
()

Get a result, potentially throwing an exception.

Method Detail

getback to summary
public T get() throws Throwable

Get a result, potentially throwing an exception.

Returns:T

a result