Interface ThrowingToLongBiFunction<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 ThrowingToLongBiFunction<T,​U,​X extends Throwable>
    Represents a function that accepts two arguments and produces a long-valued result. This is a checked-exception throwing equivalent of ToLongBiFunction.
    • Method Detail

      • applyAsLong

        long applyAsLong​(T t,
                         U u)
                  throws X extends Throwable
        Applies this function to the given arguments.
        Parameters:
        t - The first function argument.
        u - The second function argument.
        Returns:
        The function result.
        Throws:
        X - If an error occurs.
        X extends Throwable
      • onErrorThrowAsChecked

        default <E extends ThrowableThrowingToLongBiFunction<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 - If errorMapper is null.
      • onErrorThrowAsUnchecked

        default <E extends RuntimeExceptionToLongBiFunction<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 - If errorMapper is null.
      • onErrorHandleChecked

        default <E extends ThrowableThrowingToLongBiFunction<T,​U,​E> onErrorHandleChecked​(ThrowingToLongFunction<? 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 - If errorHandler is null.
      • onErrorHandleUnchecked

        default ToLongBiFunction<T,​U> onErrorHandleUnchecked​(ToLongFunction<? 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 - If errorHandler is null.
      • onErrorApplyChecked

        default <E extends ThrowableThrowingToLongBiFunction<T,​U,​E> onErrorApplyChecked​(ThrowingToLongBiFunction<? 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 fallback function if this function throws any checked exception.
        Throws:
        NullPointerException - If fallback is null.
      • onErrorApplyUnchecked

        default ToLongBiFunction<T,​U> onErrorApplyUnchecked​(ToLongBiFunction<? 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 fallback function if this function throws any checked exception.
        Throws:
        NullPointerException - If fallback is null.
      • onErrorGetChecked

        default <E extends ThrowableThrowingToLongBiFunction<T,​U,​E> onErrorGetChecked​(ThrowingLongSupplier<? 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 fallback supplier if this function throws any checked exception.
        Throws:
        NullPointerException - If fallback is null.
      • onErrorGetUnchecked

        default ToLongBiFunction<T,​U> onErrorGetUnchecked​(LongSupplier 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 fallback supplier if this function throws any checked exception.
        Throws:
        NullPointerException - If fallback is null.
      • onErrorReturn

        default ToLongBiFunction<T,​U> onErrorReturn​(long 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 fallback value if this function throws any checked exception.
      • of

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

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

        static <T,​U,​X extends ThrowableThrowingToLongBiFunction<T,​U,​X> checked​(ToLongBiFunction<? super T,​? super U> function)
        Returns a function that applies the function function to its input. Any unchecked exception thrown by the function function is relayed to the caller. This method allows existing ToLongBiFunction instances to be used where ThrowingToLongBiFunction is 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 - If function is null.
      • checked

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