Interface ThrowingLongBinaryOperator<X extends Throwable>

  • Type Parameters:
    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 ThrowingLongBinaryOperator<X extends Throwable>
    Represents an operation upon two long-valued operands and producing a long-valued result. This is a checked-exception throwing equivalent of LongBinaryOperator.
    • Method Detail

      • applyAsLong

        long applyAsLong​(long left,
                         long right)
                  throws X extends Throwable
        Applies this operator to the given operands.
        Parameters:
        left - The first operand.
        right - The second operand.
        Returns:
        The operator result.
        Throws:
        X - If an error occurs.
        X extends Throwable
      • onErrorThrowAsChecked

        default <E extends ThrowableThrowingLongBinaryOperator<E> onErrorThrowAsChecked​(Function<? super X,​? extends E> errorMapper)
        Returns a binary operator that applies this operator to its input. Any checked exception thrown by this operator is transformed using the given error mapper, and the returned operator 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 operator.
        Returns:
        A binary operator that transforms any thrown checked exception.
        Throws:
        NullPointerException - If errorMapper is null.
      • onErrorThrowAsUnchecked

        default <E extends RuntimeExceptionLongBinaryOperator onErrorThrowAsUnchecked​(Function<? super X,​? extends E> errorMapper)
        Returns a binary operator that applies this operator to its input. Any checked exception thrown by this operator is transformed using the given error mapper, and the returned operator 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 operator.
        Returns:
        A binary operator that transforms any thrown checked exception.
        Throws:
        NullPointerException - If errorMapper is null.
      • onErrorHandleChecked

        default <E extends ThrowableThrowingLongBinaryOperator<E> onErrorHandleChecked​(ThrowingToLongFunction<? super X,​? extends E> errorHandler)
        Returns a binary operator that applies this operator to its input. Any checked exception thrown by this operator is transformed using the given error handler, and the returned operator 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 operator.
        Returns:
        A binary operator that transforms any thrown checked exception.
        Throws:
        NullPointerException - If errorHandler is null.
      • onErrorHandleUnchecked

        default LongBinaryOperator onErrorHandleUnchecked​(ToLongFunction<? super X> errorHandler)
        Returns a binary operator that applies this operator to its input. Any checked exception thrown by this operator is transformed using the given error handler, and the returned operator returns the transformation result.
        Parameters:
        errorHandler - The function to use to transform any checked exception thrown by this operator.
        Returns:
        A binary operator that transforms any thrown checked exception.
        Throws:
        NullPointerException - If errorHandler is null.
      • onErrorApplyChecked

        default <E extends ThrowableThrowingLongBinaryOperator<E> onErrorApplyChecked​(ThrowingLongBinaryOperator<? extends E> fallback)
        Returns a binary operator that applies this operator to its input. If this operator throws any checked exception, it is discarded and the given fallback operator is invoked.
        Type Parameters:
        E - The type of checked exception that can be thrown by the given fallback operator.
        Parameters:
        fallback - The operator to invoke if this operator throws any checked exception.
        Returns:
        A binary operator that invokes the fallback operator if this operator throws any checked exception.
        Throws:
        NullPointerException - If fallback is null.
      • onErrorApplyUnchecked

        default LongBinaryOperator onErrorApplyUnchecked​(LongBinaryOperator fallback)
        Returns a binary operator that applies this operator to its input. If this operator throws any checked exception, it is discarded and the given fallback operator is invoked.
        Parameters:
        fallback - The operator to invoke if this operator throws any checked exception.
        Returns:
        A binary operator that invokes the fallback operator if this operator throws any checked exception.
        Throws:
        NullPointerException - If fallback is null.
      • onErrorGetChecked

        default <E extends ThrowableThrowingLongBinaryOperator<E> onErrorGetChecked​(ThrowingLongSupplier<? extends E> fallback)
        Returns a binary operator that applies this operator to its input. If this operator 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 operator throws any checked exception.
        Returns:
        A binary operator that invokes the fallback supplier if this operator throws any checked exception.
        Throws:
        NullPointerException - If fallback is null.
      • onErrorGetUnchecked

        default LongBinaryOperator onErrorGetUnchecked​(LongSupplier fallback)
        Returns a binary operator that applies this operator to its input. If this operator 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 operator throws any checked exception.
        Returns:
        A binary operator that invokes the fallback supplier if this operator throws any checked exception.
        Throws:
        NullPointerException - If fallback is null.
      • onErrorReturn

        default LongBinaryOperator onErrorReturn​(long fallback)
        Returns a binary operator that applies this operator to its input. If this operator throws any checked exception, it is discarded and the given fallback value is returned.
        Parameters:
        fallback - The value to return if this operator throws any checked exception.
        Returns:
        A binary operator that returns the fallback value if this operator throws any checked exception.
      • of

        static <X extends ThrowableThrowingLongBinaryOperator<X> of​(ThrowingLongBinaryOperator<X> operator)
        Factory method for turning ThrowingLongBinaryOperator-shaped lambdas into ThrowingLongBinaryOpreators.
        Type Parameters:
        X - The type of checked exception that can be thrown.
        Parameters:
        operator - The lambda to return as ThrowingLongBinaryOperator.
        Returns:
        The given lambda as a ThrowingLongBinaryOperator.
        Throws:
        NullPointerException - If operator is null.
      • checked

        static <X extends ThrowableThrowingLongBinaryOperator<X> checked​(LongBinaryOperator operator)
        Returns a binary operator that applies the operator operator to its input. Any unchecked exception thrown by the operator operator is relayed to the caller. This method allows existing LongBinaryOperator instances to be used where ThrowingLongBinaryOperator is expected.
        Type Parameters:
        X - The type of checked exception that can be thrown.
        Parameters:
        operator - The operator to apply when the returned operator is applied.
        Returns:
        A binary operator that wraps any checked exception in an UncheckedException.
        Throws:
        NullPointerException - If operator is null.
      • checked

        static <X extends ThrowableThrowingLongBinaryOperator<X> checked​(LongBinaryOperator operator,
                                                                           Class<X> errorType)
        Returns a binary operator that applies the operator operator to its input. Any UncheckedException thrown by the operator operator is unwrapped if its cause is an instance of errorType, otherwise it is relayed to the caller.
        Type Parameters:
        X - The type of checked exception that can be thrown.
        Parameters:
        operator - The operator to apply when the returned 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.