Interface ThrowingBinaryOperator<T,X extends Throwable>
-
- Type Parameters:
T- The type of the operands and result of the operator.X- The type of checked exception that can be thrown.
- All Superinterfaces:
ThrowingBiFunction<T,T,T,X>
- 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 ThrowingBinaryOperator<T,X extends Throwable> extends ThrowingBiFunction<T,T,T,X>
Represents an operation upon two operands of the same type, producing a result of the same type as the operands. This is a checked-exception throwing equivalent ofBinaryOperator.
-
-
Method Summary
All Methods Static Methods Instance Methods Default Methods Modifier and Type Method Description static <T,X extends Throwable>
ThrowingBinaryOperator<T,X>checked(BinaryOperator<T> operator)Returns a binary operator that applies theoperatorbinary operator to its input.static <T,X extends Throwable>
ThrowingBinaryOperator<T,X>checked(BinaryOperator<T> operator, Class<X> errorType)Returns a binary operator that applies theoperatorbinary operator to its input.static <T,X extends Throwable>
ThrowingBinaryOperator<T,X>of(ThrowingBinaryOperator<T,X> operator)Factory method for turningThrowingBinaryOperator-shaped lambdas intoThrowingBinaryOperators.default <E extends Throwable>
ThrowingBinaryOperator<T,E>onErrorApplyChecked(ThrowingBiFunction<? super T,? super T,? extends T,? extends E> fallback)Returns a function that applies this function to its input.default BinaryOperator<T>onErrorApplyUnchecked(BiFunction<? super T,? super T,? extends T> fallback)Returns a function that applies this function to its input.default <E extends Throwable>
ThrowingBinaryOperator<T,E>onErrorGetChecked(ThrowingSupplier<? extends T,? extends E> fallback)Returns a function that applies this function to its input.default BinaryOperator<T>onErrorGetUnchecked(Supplier<? extends T> fallback)Returns a function that applies this function to its input.default <E extends Throwable>
ThrowingBinaryOperator<T,E>onErrorHandleChecked(ThrowingFunction<? super X,? extends T,? extends E> errorHandler)Returns a function that applies this function to its input.default BinaryOperator<T>onErrorHandleUnchecked(Function<? super X,? extends T> errorHandler)Returns a function that applies this function to its input.default BinaryOperator<T>onErrorReturn(T fallback)Returns a function that applies this function to its input.default <E extends Throwable>
ThrowingBinaryOperator<T,E>onErrorThrowAsChecked(Function<? super X,? extends E> errorMapper)Returns a function that applies this function to its input.default <E extends RuntimeException>
BinaryOperator<T>onErrorThrowAsUnchecked(Function<? super X,? extends E> errorMapper)Returns a function that applies this function to its input.default BinaryOperator<T>unchecked()Returns a function that applies this function to its input.static <T> BinaryOperator<T>unchecked(ThrowingBinaryOperator<T,?> operator)Returns a binary operator that applies theoperatorbinary operator to its input.-
Methods inherited from interface com.github.robtimus.function.throwing.ThrowingBiFunction
andThen, apply
-
-
-
-
Method Detail
-
onErrorThrowAsChecked
default <E extends Throwable> ThrowingBinaryOperator<T,E> onErrorThrowAsChecked(Function<? super X,? extends E> errorMapper)
Description copied from interface:ThrowingBiFunctionReturns 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.- Specified by:
onErrorThrowAsCheckedin interfaceThrowingBiFunction<T,T,T,X extends Throwable>- 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.
-
onErrorThrowAsUnchecked
default <E extends RuntimeException> BinaryOperator<T> onErrorThrowAsUnchecked(Function<? super X,? extends E> errorMapper)
Description copied from interface:ThrowingBiFunctionReturns 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.- Specified by:
onErrorThrowAsUncheckedin interfaceThrowingBiFunction<T,T,T,X extends Throwable>- 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.
-
onErrorHandleChecked
default <E extends Throwable> ThrowingBinaryOperator<T,E> onErrorHandleChecked(ThrowingFunction<? super X,? extends T,? extends E> errorHandler)
Description copied from interface:ThrowingBiFunctionReturns 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.- Specified by:
onErrorHandleCheckedin interfaceThrowingBiFunction<T,T,T,X extends Throwable>- 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.
-
onErrorHandleUnchecked
default BinaryOperator<T> onErrorHandleUnchecked(Function<? super X,? extends T> errorHandler)
Description copied from interface:ThrowingBiFunctionReturns 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.- Specified by:
onErrorHandleUncheckedin interfaceThrowingBiFunction<T,T,T,X extends Throwable>- Parameters:
errorHandler- The function to use to transform any checked exception thrown by this function.- Returns:
- A function that transforms any thrown checked exception.
-
onErrorApplyChecked
default <E extends Throwable> ThrowingBinaryOperator<T,E> onErrorApplyChecked(ThrowingBiFunction<? super T,? super T,? extends T,? extends E> fallback)
Description copied from interface:ThrowingBiFunctionReturns 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.- Specified by:
onErrorApplyCheckedin interfaceThrowingBiFunction<T,T,T,X extends Throwable>- 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.
-
onErrorApplyUnchecked
default BinaryOperator<T> onErrorApplyUnchecked(BiFunction<? super T,? super T,? extends T> fallback)
Description copied from interface:ThrowingBiFunctionReturns 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.- Specified by:
onErrorApplyUncheckedin interfaceThrowingBiFunction<T,T,T,X extends Throwable>- 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.
-
onErrorGetChecked
default <E extends Throwable> ThrowingBinaryOperator<T,E> onErrorGetChecked(ThrowingSupplier<? extends T,? extends E> fallback)
Description copied from interface:ThrowingBiFunctionReturns 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.- Specified by:
onErrorGetCheckedin interfaceThrowingBiFunction<T,T,T,X extends Throwable>- 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.
-
onErrorGetUnchecked
default BinaryOperator<T> onErrorGetUnchecked(Supplier<? extends T> fallback)
Description copied from interface:ThrowingBiFunctionReturns 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.- Specified by:
onErrorGetUncheckedin interfaceThrowingBiFunction<T,T,T,X extends Throwable>- 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.
-
onErrorReturn
default BinaryOperator<T> onErrorReturn(T fallback)
Description copied from interface:ThrowingBiFunctionReturns 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.- Specified by:
onErrorReturnin interfaceThrowingBiFunction<T,T,T,X extends Throwable>- 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 BinaryOperator<T> unchecked()
Description copied from interface:ThrowingBiFunctionReturns a function that applies this function to its input. Any checked exception thrown by this function is wrapped in anUncheckedExceptionwithout a stack trace.- Specified by:
uncheckedin interfaceThrowingBiFunction<T,T,T,X extends Throwable>- Returns:
- A function that wraps any checked exception in an
UncheckedException.
-
of
static <T,X extends Throwable> ThrowingBinaryOperator<T,X> of(ThrowingBinaryOperator<T,X> operator)
Factory method for turningThrowingBinaryOperator-shaped lambdas intoThrowingBinaryOperators.- Type Parameters:
T- The type of the operands and result of the operator.X- The type of checked exception that can be thrown.- Parameters:
operator- The lambda to return asThrowingBinaryOperator.- Returns:
- The given lambda as a
ThrowingBinaryOperator. - Throws:
NullPointerException- Ifoperatorisnull.
-
unchecked
static <T> BinaryOperator<T> unchecked(ThrowingBinaryOperator<T,?> operator)
Returns a binary operator that applies theoperatorbinary operator to its input. Any checked exception thrown by theoperatorbinary operator is wrapped in anUncheckedException.- Type Parameters:
T- The type of the operands and result of the operator.- Parameters:
operator- The binary operator to apply when the returned binary operator is applied.- Returns:
- A binary operator that wraps any checked exception in an
UncheckedException. - Throws:
NullPointerException- Ifoperatorisnull.
-
checked
static <T,X extends Throwable> ThrowingBinaryOperator<T,X> checked(BinaryOperator<T> operator)
Returns a binary operator that applies theoperatorbinary operator to its input. Any unchecked exception thrown by theoperatorbinary operator is relayed to the caller. This method allows existingBinaryOperatorinstances to be used whereThrowingBinaryOperatoris expected.- Type Parameters:
T- The type of the operands and result of the operator.X- The type of checked exception that can be thrown.- Parameters:
operator- The binary operator to apply when the returned binary operator is applied.- Returns:
- A binary operator that wraps any checked exception in an
UncheckedException. - Throws:
NullPointerException- Ifoperatorisnull.
-
checked
static <T,X extends Throwable> ThrowingBinaryOperator<T,X> checked(BinaryOperator<T> operator, Class<X> errorType)
Returns a binary operator that applies theoperatorbinary operator to its input. AnyUncheckedExceptionthrown by theoperatorbinary operator is unwrapped if its cause is an instance oferrorType, otherwise it is relayed to the caller.- Type Parameters:
T- The type of the operands and result of the operator.X- The type of checked exception that can be thrown.- Parameters:
operator- The binary operator to apply when the returned binary operator is applied.errorType- The type of checked exception that can be thrown.- Returns:
- A binary operator that wraps any checked exception in an
UncheckedException. - Throws:
NullPointerException- IfoperatororerrorTypeisnull.
-
-