Module net.luis.utils
Interface ThrowableSupplier<T,X extends Throwable>
- Type Parameters:
T
- The return typeX
- The exception that can be thrown
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Functional interface that takes no arguments and returns a value.
The
The class is equivalent to
The
FunctionalInterface
method is get()
.The class is equivalent to
Supplier
, but the functional method can throw a checked exception.-
Method Summary
-
Method Details
-
caught
@NotNull static <T> @NotNull Supplier<T> caught(@NotNull @NotNull ThrowableSupplier<T, ? extends Throwable> supplier) Converts a throwable supplier into a supplier that throws a runtime exception when an exception is thrown.- Type Parameters:
T
- The type of the result- Parameters:
supplier
- The throwable supplier- Returns:
- A caught supplier
- Throws:
NullPointerException
- If the throwable supplier is null
-
get
Returns the result of the supplier.- Returns:
- The result
- Throws:
X
- The exception that can be thrown
-