T
- the type of results supplied by this supplier@FunctionalInterface public interface ThrowingSupplier<T> extends Supplier<T>
ThrowingSupplier
s can throw any kind of Exception
. When used
as Supplier
exceptions are hidden from compiler.
This is a functional interface whose
functional method is get()
.
Modifier and Type | Method and Description |
---|---|
default T |
get()
Gets a result, allow throwing any kind of
Exception . |
T |
getThrowing()
Gets a result, allow throwing any kind of
Exception . |
static <T> Supplier<T> |
throwing(ThrowingSupplier<T> supplier)
Short-hand method to cast any
ThrowingSupplier as Supplier . |
static <T> Supplier<T> throwing(ThrowingSupplier<T> supplier)
ThrowingSupplier
as Supplier
.T
- the type of results supplied by this suppliersupplier
- throwing supplier@Nullable default T get()
Exception
.
As this hides exceptions from the compiler, the calling method should either:
throws
statement for the hidden exceptions
catch
@throws
.
get
in interface Supplier<T>
SneakyException
- hidden exceptionsCopyright © 2025. All rights reserved.