T
- the type of the input to the functionR
- the type of the result of the function@FunctionalInterface public interface ThrowingFunction<T,R> extends Function<T,R>
ThrowingFunction
s can throw any kind of Exception
. When used
as Function
exceptions are hidden from compiler.
This is a functional interface whose
functional method is applyThrowing(Object)
.
Modifier and Type | Method and Description |
---|---|
default R |
apply(T value)
Applies this function to the given argument, allow throwing any kind of
Exception . |
R |
applyThrowing(T value)
Applies this function to the given argument, allow throwing any kind of
Exception . |
static <T,R> Function<T,R> |
throwing(ThrowingFunction<T,R> function)
Short-hand method to cast any
ThrowingFunction as Function . |
static <T,R> Function<T,R> throwing(ThrowingFunction<T,R> function)
ThrowingFunction
as Function
.T
- the type of the input to the functionR
- the type of the result of the functionfunction
- throwing function@Nullable default R apply(@Nullable T value)
Exception
.
As this hides exceptions from the compiler, the calling method should either:
throws
statement for the hidden exceptions
catch
@throws
.
apply
in interface Function<T,R>
value
- the function argumentSneakyException
- hidden exceptionsCopyright © 2025. All rights reserved.