Top Description Methods
org.springframework.util.function

public Interface ThrowingBiFunction<T, U, R>

extends BiFunction<T, U, R>
Type Parameters
<T>
the type of the first argument to the function
<U>
the type of the second argument to the function
<R>
the type of the result of the function
Imports
java.util.function.BiFunction

A BiFunction that allows invocation of code that throws a checked exception.
Authors
Stephane Nicoll, Phillip Webb
Since
6.0

Method Summary

Modifier and TypeMethod and Description
public default R

Returns:

the function result
apply
(T
the first function argument
t
,
U
the second function argument
u
)

Implements java.util.function.BiFunction.apply.

Default BiFunction#apply(Object, Object) that wraps any thrown checked exceptions (by default in a RuntimeException).
public default R

Returns:

a result
apply
(T
the first function argument
t
,
U
the second function argument
u
,
BiFunction<String, Exception, RuntimeException>
BiFunction that wraps the given message and checked exception into a runtime exception
exceptionWrapper
)

Applies this function to the given argument, wrapping any thrown checked exceptions using the given exceptionWrapper.

public R

Returns:

the function result
applyWithException
(T
the first function argument
t
,
U
the second function argument
u
)

Applies this function to the given argument, possibly throwing a checked exception.

public static <
the type of the first argument to the function
T
,
the type of the second argument to the function
U
,
the type of the result of the function
R
>
ThrowingBiFunction<T, U, R>

Returns:

a new ThrowingFunction instance
of
(ThrowingBiFunction<T, U, R>
the source function
function
)

Lambda friendly convenience method that can be used to create a ThrowingBiFunction where the apply(Object, Object) method wraps any checked exception thrown by the supplied lambda expression or method reference.

public static <
the type of the first argument to the function
T
,
the type of the second argument to the function
U
,
the type of the result of the function
R
>
ThrowingBiFunction<T, U, R>

Returns:

a new ThrowingFunction instance
of
(ThrowingBiFunction<T, U, R>
the source function
function
,
BiFunction<String, Exception, RuntimeException>
the exception wrapper to use
exceptionWrapper
)

Lambda friendly convenience method that can be used to create a ThrowingBiFunction where the apply(Object, Object) method wraps any thrown checked exceptions using the given exceptionWrapper.

public default ThrowingBiFunction<T, U, R>

Returns:

the replacement ThrowingBiFunction instance
throwing
(BiFunction<String, Exception, RuntimeException>
BiFunction that wraps the given message and checked exception into a runtime exception
exceptionWrapper
)

Return a new ThrowingBiFunction where the apply(Object, Object) method wraps any thrown checked exceptions using the given exceptionWrapper.

Inherited from java.util.function.BiFunction:
andThen

Method Detail

applyback to summary
public default R apply(T t, U u)

Implements java.util.function.BiFunction.apply.

Default BiFunction#apply(Object, Object) that wraps any thrown checked exceptions (by default in a RuntimeException).

Parameters
t:T

the first function argument

u:U

the second function argument

Returns:R

the function result

Annotations
@Override
See Also
java.util.function.BiFunction#apply(Object, Object)
applyback to summary
public default R apply(T t, U u, BiFunction<String, Exception, RuntimeException> exceptionWrapper)

Applies this function to the given argument, wrapping any thrown checked exceptions using the given exceptionWrapper.

Parameters
t:T

the first function argument

u:U

the second function argument

exceptionWrapper:BiFunction<String, Exception, RuntimeException>

BiFunction that wraps the given message and checked exception into a runtime exception

Returns:R

a result

applyWithExceptionback to summary
public R applyWithException(T t, U u) throws Exception

Applies this function to the given argument, possibly throwing a checked exception.

Parameters
t:T

the first function argument

u:U

the second function argument

Returns:R

the function result

Exceptions
Exception:
on error
ofback to summary
public static <T, U, R> ThrowingBiFunction<T, U, R> of(ThrowingBiFunction<T, U, R> function)

Lambda friendly convenience method that can be used to create a ThrowingBiFunction where the apply(Object, Object) method wraps any checked exception thrown by the supplied lambda expression or method reference.

This method can be especially useful when working with method references. It allows you to easily convert a method that throws a checked exception into an instance compatible with a regular BiFunction.

For example:

map.replaceAll(ThrowingBiFunction.of(Example::methodThatCanThrowCheckedException));
Parameters
<T>
the type of the first argument to the function
<U>
the type of the second argument to the function
<R>
the type of the result of the function
function:ThrowingBiFunction<T, U, R>

the source function

Returns:ThrowingBiFunction<T, U, R>

a new ThrowingFunction instance

ofback to summary
public static <T, U, R> ThrowingBiFunction<T, U, R> of(ThrowingBiFunction<T, U, R> function, BiFunction<String, Exception, RuntimeException> exceptionWrapper)

Lambda friendly convenience method that can be used to create a ThrowingBiFunction where the apply(Object, Object) method wraps any thrown checked exceptions using the given exceptionWrapper.

This method can be especially useful when working with method references. It allows you to easily convert a method that throws a checked exception into an instance compatible with a regular BiFunction.

For example:

map.replaceAll(ThrowingBiFunction.of(Example::methodThatCanThrowCheckedException, IllegalStateException::new));
Parameters
<T>
the type of the first argument to the function
<U>
the type of the second argument to the function
<R>
the type of the result of the function
function:ThrowingBiFunction<T, U, R>

the source function

exceptionWrapper:BiFunction<String, Exception, RuntimeException>

the exception wrapper to use

Returns:ThrowingBiFunction<T, U, R>

a new ThrowingFunction instance

throwingback to summary
public default ThrowingBiFunction<T, U, R> throwing(BiFunction<String, Exception, RuntimeException> exceptionWrapper)

Return a new ThrowingBiFunction where the apply(Object, Object) method wraps any thrown checked exceptions using the given exceptionWrapper.

Parameters
exceptionWrapper:BiFunction<String, Exception, RuntimeException>

BiFunction that wraps the given message and checked exception into a runtime exception

Returns:ThrowingBiFunction<T, U, R>

the replacement ThrowingBiFunction instance