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 of BinaryOperator.
    • Method Detail

      • onErrorThrowAsChecked

        default <E extends ThrowableThrowingBinaryOperator<T,​E> onErrorThrowAsChecked​(Function<? super X,​? extends E> errorMapper)
        Description copied from interface: ThrowingBiFunction
        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.
        Specified by:
        onErrorThrowAsChecked in interface ThrowingBiFunction<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 RuntimeExceptionBinaryOperator<T> onErrorThrowAsUnchecked​(Function<? super X,​? extends E> errorMapper)
        Description copied from interface: ThrowingBiFunction
        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.
        Specified by:
        onErrorThrowAsUnchecked in interface ThrowingBiFunction<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 ThrowableThrowingBinaryOperator<T,​E> onErrorHandleChecked​(ThrowingFunction<? super X,​? extends T,​? extends E> errorHandler)
        Description copied from interface: ThrowingBiFunction
        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.
        Specified by:
        onErrorHandleChecked in interface ThrowingBiFunction<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: ThrowingBiFunction
        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.
        Specified by:
        onErrorHandleUnchecked in interface ThrowingBiFunction<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 ThrowableThrowingBinaryOperator<T,​E> onErrorApplyChecked​(ThrowingBiFunction<? super T,​? super T,​? extends T,​? extends E> fallback)
        Description copied from interface: ThrowingBiFunction
        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.
        Specified by:
        onErrorApplyChecked in interface ThrowingBiFunction<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 fallback function if this function throws any checked exception.
      • onErrorApplyUnchecked

        default BinaryOperator<T> onErrorApplyUnchecked​(BiFunction<? super T,​? super T,​? extends T> fallback)
        Description copied from interface: ThrowingBiFunction
        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.
        Specified by:
        onErrorApplyUnchecked in interface ThrowingBiFunction<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 fallback function if this function throws any checked exception.
      • onErrorGetChecked

        default <E extends ThrowableThrowingBinaryOperator<T,​E> onErrorGetChecked​(ThrowingSupplier<? extends T,​? extends E> fallback)
        Description copied from interface: ThrowingBiFunction
        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.
        Specified by:
        onErrorGetChecked in interface ThrowingBiFunction<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 fallback supplier if this function throws any checked exception.
      • onErrorGetUnchecked

        default BinaryOperator<T> onErrorGetUnchecked​(Supplier<? extends T> fallback)
        Description copied from interface: ThrowingBiFunction
        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.
        Specified by:
        onErrorGetUnchecked in interface ThrowingBiFunction<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 fallback supplier if this function throws any checked exception.
      • onErrorReturn

        default BinaryOperator<T> onErrorReturn​(T fallback)
        Description copied from interface: ThrowingBiFunction
        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.
        Specified by:
        onErrorReturn in interface ThrowingBiFunction<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 fallback value if this function throws any checked exception.
      • of

        static <T,​X extends ThrowableThrowingBinaryOperator<T,​X> of​(ThrowingBinaryOperator<T,​X> operator)
        Factory method for turning ThrowingBinaryOperator-shaped lambdas into ThrowingBinaryOperators.
        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 as ThrowingBinaryOperator.
        Returns:
        The given lambda as a ThrowingBinaryOperator.
        Throws:
        NullPointerException - If operator is null.
      • unchecked

        static <T> BinaryOperator<T> unchecked​(ThrowingBinaryOperator<T,​?> operator)
        Returns a binary operator that applies the operator binary operator to its input. Any checked exception thrown by the operator binary operator is wrapped in an UncheckedException.
        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 - If operator is null.
      • checked

        static <T,​X extends ThrowableThrowingBinaryOperator<T,​X> checked​(BinaryOperator<T> operator)
        Returns a binary operator that applies the operator binary operator to its input. Any unchecked exception thrown by the operator binary operator is relayed to the caller. This method allows existing BinaryOperator instances to be used where ThrowingBinaryOperator is 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 - If operator is null.
      • checked

        static <T,​X extends ThrowableThrowingBinaryOperator<T,​X> checked​(BinaryOperator<T> operator,
                                                                                       Class<X> errorType)
        Returns a binary operator that applies the operator binary operator to its input. Any UncheckedException thrown by the operator binary operator is unwrapped if its cause is an instance of errorType, 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 - If operator or errorType is null.