Interface ThrowingDoubleToLongFunction<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 ThrowingDoubleToLongFunction<X extends Throwable>
    Represents a function that accepts a double-valued argument and produces a long-valued result. This is a checked-exception throwing equivalent of DoubleToLongFunction.
    • Method Detail

      • applyAsLong

        long applyAsLong​(double value)
                  throws X extends Throwable
        Applies this function to the given argument.
        Parameters:
        value - The function argument.
        Returns:
        The function result.
        Throws:
        X - If an error occurs.
        X extends Throwable
      • onErrorThrowAsChecked

        default <E extends ThrowableThrowingDoubleToLongFunction<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 RuntimeExceptionDoubleToLongFunction 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 ThrowableThrowingDoubleToLongFunction<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 DoubleToLongFunction 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 ThrowableThrowingDoubleToLongFunction<E> onErrorApplyChecked​(ThrowingDoubleToLongFunction<? 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 DoubleToLongFunction onErrorApplyUnchecked​(DoubleToLongFunction 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 ThrowableThrowingDoubleToLongFunction<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 DoubleToLongFunction 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 DoubleToLongFunction 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 <X extends ThrowableThrowingDoubleToLongFunction<X> of​(ThrowingDoubleToLongFunction<X> function)
        Factory method for turning ThrowingDoubleToLongFunction-shaped lambdas into ThrowingDoubleToLongFunctions.
        Type Parameters:
        X - The type of checked exception that can be thrown.
        Parameters:
        function - The lambda to return as ThrowingDoubleToLongFunction.
        Returns:
        The given lambda as a ThrowingDoubleToLongFunction.
        Throws:
        NullPointerException - If function is null.
      • checked

        static <X extends ThrowableThrowingDoubleToLongFunction<X> checked​(DoubleToLongFunction 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 DoubleToLongFunction instances to be used where ThrowingDoubleToLongFunction is expected.
        Type Parameters:
        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 <X extends ThrowableThrowingDoubleToLongFunction<X> checked​(DoubleToLongFunction 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:
        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.