Interface ThrowingToIntBiFunction<T,U,X extends Throwable>
-
- Type Parameters:
T- The type of the first argument to the function.U- The type of the second argument to the function.X- The type of checked 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.
@FunctionalInterface public interface ThrowingToIntBiFunction<T,U,X extends Throwable>
Represents a function that accepts two arguments and produces anint-valued result. This is a checked-exception throwing equivalent ofToIntBiFunction.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description intapplyAsInt(T t, U u)Applies this function to the given arguments.static <T,U,X extends Throwable>
ThrowingToIntBiFunction<T,U,X>checked(ToIntBiFunction<? super T,? super U> function)Returns a function that applies thefunctionfunction to its input.static <T,U,X extends Throwable>
ThrowingToIntBiFunction<T,U,X>checked(ToIntBiFunction<? super T,? super U> function, Class<X> errorType)Returns a function that applies thefunctionfunction to its input.static <T,U,X extends Throwable>
ThrowingToIntBiFunction<T,U,X>of(ThrowingToIntBiFunction<T,U,X> function)Factory method for turningThrowingToIntBiFunction-shaped lambdas intoThrowingToIntBiFunctions.default <E extends Throwable>
ThrowingToIntBiFunction<T,U,E>onErrorApplyChecked(ThrowingToIntBiFunction<? super T,? super U,? extends E> fallback)Returns a function that applies this function to its input.default ToIntBiFunction<T,U>onErrorApplyUnchecked(ToIntBiFunction<? super T,? super U> fallback)Returns a function that applies this function to its input.default <E extends Throwable>
ThrowingToIntBiFunction<T,U,E>onErrorGetChecked(ThrowingIntSupplier<? extends E> fallback)Returns a function that applies this function to its input.default ToIntBiFunction<T,U>onErrorGetUnchecked(IntSupplier fallback)Returns a function that applies this function to its input.default <E extends Throwable>
ThrowingToIntBiFunction<T,U,E>onErrorHandleChecked(ThrowingToIntFunction<? super X,? extends E> errorHandler)Returns a function that applies this function to its input.default ToIntBiFunction<T,U>onErrorHandleUnchecked(ToIntFunction<? super X> errorHandler)Returns a function that applies this function to its input.default ToIntBiFunction<T,U>onErrorReturn(int fallback)Returns a function that applies this function to its input.default <E extends Throwable>
ThrowingToIntBiFunction<T,U,E>onErrorThrowAsChecked(Function<? super X,? extends E> errorMapper)Returns a function that applies this function to its input.default <E extends RuntimeException>
ToIntBiFunction<T,U>onErrorThrowAsUnchecked(Function<? super X,? extends E> errorMapper)Returns a function that applies this function to its input.default ToIntBiFunction<T,U>unchecked()Returns a function that applies this function to its input.static <T,U>
ToIntBiFunction<T,U>unchecked(ThrowingToIntBiFunction<? super T,? super U,?> function)Returns a function that applies thefunctionfunction to its input.
-
-
-
Method Detail
-
applyAsInt
int applyAsInt(T t, U u) throws X extends Throwable
Applies this function to the given arguments.
-
onErrorThrowAsChecked
default <E extends Throwable> ThrowingToIntBiFunction<T,U,E> onErrorThrowAsChecked(Function<? super X,? extends E> errorMapper)
Returns a function that applies this function to its input. Any checked exception thrown by this function is transformed using the given error mapper, and the returned function throws the transformation result.- Type Parameters:
E- The type of checked exception to transform to.- Parameters:
errorMapper- The function to use to transform any checked exception thrown by this function.- Returns:
- A function that transforms any thrown checked exception.
- Throws:
NullPointerException- IferrorMapperisnull.
-
onErrorThrowAsUnchecked
default <E extends RuntimeException> ToIntBiFunction<T,U> onErrorThrowAsUnchecked(Function<? super X,? extends E> errorMapper)
Returns a function that applies this function to its input. Any checked exception thrown by this function is transformed using the given error mapper, and the returned function throws the transformation result.- Type Parameters:
E- The type of unchecked exception to transform to.- Parameters:
errorMapper- The function to use to transform any checked exception thrown by this function.- Returns:
- A function that transforms any thrown checked exception.
- Throws:
NullPointerException- IferrorMapperisnull.
-
onErrorHandleChecked
default <E extends Throwable> ThrowingToIntBiFunction<T,U,E> onErrorHandleChecked(ThrowingToIntFunction<? super X,? extends E> errorHandler)
Returns a function that applies this function to its input. Any checked exception thrown by this function is transformed using the given error handler, and the returned function returns the transformation result.- Type Parameters:
E- The type of checked exception that can be thrown by the given error handler.- Parameters:
errorHandler- The function to use to transform any checked exception thrown by this function.- Returns:
- A function that transforms any thrown checked exception.
- Throws:
NullPointerException- IferrorHandlerisnull.
-
onErrorHandleUnchecked
default ToIntBiFunction<T,U> onErrorHandleUnchecked(ToIntFunction<? super X> errorHandler)
Returns a function that applies this function to its input. Any checked exception thrown by this function is transformed using the given error handler, and the returned function returns the transformation result.- Parameters:
errorHandler- The function to use to transform any checked exception thrown by this function.- Returns:
- A function that transforms any thrown checked exception.
- Throws:
NullPointerException- IferrorHandlerisnull.
-
onErrorApplyChecked
default <E extends Throwable> ThrowingToIntBiFunction<T,U,E> onErrorApplyChecked(ThrowingToIntBiFunction<? super T,? super U,? extends E> fallback)
Returns a function that applies this function to its input. If this function throws any checked exception, it is discarded and the given fallback function is invoked.- Type Parameters:
E- The type of checked exception that can be thrown by the given fallback function.- Parameters:
fallback- The function to invoke if this function throws any checked exception.- Returns:
- A function that invokes the
fallbackfunction if this function throws any checked exception. - Throws:
NullPointerException- Iffallbackisnull.
-
onErrorApplyUnchecked
default ToIntBiFunction<T,U> onErrorApplyUnchecked(ToIntBiFunction<? super T,? super U> fallback)
Returns a function that applies this function to its input. If this function throws any checked exception, it is discarded and the given fallback function is invoked.- Parameters:
fallback- The function to invoke if this function throws any checked exception.- Returns:
- A function that invokes the
fallbackfunction if this function throws any checked exception. - Throws:
NullPointerException- Iffallbackisnull.
-
onErrorGetChecked
default <E extends Throwable> ThrowingToIntBiFunction<T,U,E> onErrorGetChecked(ThrowingIntSupplier<? extends E> fallback)
Returns a function that applies this function to its input. If this function throws any checked exception, it is discarded and the given fallback supplier is invoked.- Type Parameters:
E- The type of checked exception that can be thrown by the given fallback supplier.- Parameters:
fallback- The supplier to produce the value to return if this function throws any checked exception.- Returns:
- A function that invokes the
fallbacksupplier if this function throws any checked exception. - Throws:
NullPointerException- Iffallbackisnull.
-
onErrorGetUnchecked
default ToIntBiFunction<T,U> onErrorGetUnchecked(IntSupplier fallback)
Returns a function that applies this function to its input. If this function throws any checked exception, it is discarded and the given fallback supplier is invoked.- Parameters:
fallback- The supplier to produce the value to return if this function throws any checked exception.- Returns:
- A function that invokes the
fallbacksupplier if this function throws any checked exception. - Throws:
NullPointerException- Iffallbackisnull.
-
onErrorReturn
default ToIntBiFunction<T,U> onErrorReturn(int fallback)
Returns a function that applies this function to its input. If this function throws any checked exception, it is discarded and the given fallback value is returned.- Parameters:
fallback- The value to return if this function throws any checked exception.- Returns:
- A function that returns the
fallbackvalue if this function throws any checked exception.
-
unchecked
default ToIntBiFunction<T,U> unchecked()
Returns a function that applies this function to its input. Any checked exception thrown by this function is wrapped in anUncheckedExceptionwithout a stack trace.- Returns:
- A function that wraps any checked exception in an
UncheckedException.
-
of
static <T,U,X extends Throwable> ThrowingToIntBiFunction<T,U,X> of(ThrowingToIntBiFunction<T,U,X> function)
Factory method for turningThrowingToIntBiFunction-shaped lambdas intoThrowingToIntBiFunctions.- Type Parameters:
T- The type of the first argument to the function.U- The type of the second argument to the function.X- The type of checked exception that can be thrown.- Parameters:
function- The lambda to return asThrowingToIntBiFunction.- Returns:
- The given lambda as a
ThrowingToIntBiFunction. - Throws:
NullPointerException- Iffunctionisnull.
-
unchecked
static <T,U> ToIntBiFunction<T,U> unchecked(ThrowingToIntBiFunction<? super T,? super U,?> function)
Returns a function that applies thefunctionfunction to its input. Any checked exception thrown by thefunctionfunction is wrapped in anUncheckedException.- Type Parameters:
T- The type of the first argument to the function.U- The type of the second argument to the function.- Parameters:
function- The function to apply when the returned function is applied.- Returns:
- A function that wraps any checked exception in an
UncheckedException. - Throws:
NullPointerException- Iffunctionisnull.
-
checked
static <T,U,X extends Throwable> ThrowingToIntBiFunction<T,U,X> checked(ToIntBiFunction<? super T,? super U> function)
Returns a function that applies thefunctionfunction to its input. Any unchecked exception thrown by thefunctionfunction is relayed to the caller. This method allows existingToIntBiFunctioninstances to be used whereThrowingToIntBiFunctionis expected.- Type Parameters:
T- The type of the first argument to the function.U- The type of the second argument to the function.X- The type of checked exception that can be thrown.- Parameters:
function- The function to apply when the returned function is applied.- Returns:
- A function that wraps any checked exception in an
UncheckedException. - Throws:
NullPointerException- Iffunctionisnull.
-
checked
static <T,U,X extends Throwable> ThrowingToIntBiFunction<T,U,X> checked(ToIntBiFunction<? super T,? super U> function, Class<X> errorType)
Returns a function that applies thefunctionfunction to its input. AnyUncheckedExceptionthrown by thefunctionfunction is unwrapped if its cause is an instance oferrorType, otherwise it is relayed to the caller.- Type Parameters:
T- The type of the first argument to the function.U- The type of the second argument to the function.X- The type of checked exception that can be thrown.- Parameters:
function- The function to apply when the returned function is applied.errorType- The type of checked exception that can be thrown.- Returns:
- A function that wraps any checked exception in an
UncheckedException. - Throws:
NullPointerException- IffunctionorerrorTypeisnull.
-
-