Interface ThrowingDoubleSupplier<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 ThrowingDoubleSupplier<X extends Throwable>
    Represents a supplier of double-valued results. This is a checked-exception throwing equivalent of DoubleSupplier.
    • Method Detail

      • getAsDouble

        double getAsDouble()
                    throws X extends Throwable
        Gets a result.
        Returns:
        A result.
        Throws:
        X - If an error occurs.
        X extends Throwable
      • onErrorThrowAsChecked

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

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

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

        default DoubleSupplier onErrorHandleUnchecked​(ToDoubleFunction<? super X> errorHandler)
        Returns a supplier that calls this supplier. Any checked exception thrown by this supplier is transformed using the given error handler, and the returned supplier returns the transformation result.
        Parameters:
        errorHandler - The function to use to transform any checked exception thrown by this supplier.
        Returns:
        A supplier that transforms any thrown checked exception.
        Throws:
        NullPointerException - If errorHandler is null.
      • onErrorGetCheckedAsDouble

        default <E extends ThrowableThrowingDoubleSupplier<E> onErrorGetCheckedAsDouble​(ThrowingDoubleSupplier<? extends E> fallback)
        Returns a supplier that calls this supplier. If this supplier 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 supplier throws any checked exception.
        Returns:
        A supplier that invokes the fallback supplier if this supplier throws any checked exception.
        Throws:
        NullPointerException - If fallback is null.
      • onErrorGetUncheckedAsDouble

        default DoubleSupplier onErrorGetUncheckedAsDouble​(DoubleSupplier fallback)
        Returns a supplier that calls this supplier. If this supplier 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 supplier throws any checked exception.
        Returns:
        A supplier that invokes the fallback supplier if this supplier throws any checked exception.
        Throws:
        NullPointerException - If fallback is null.
      • onErrorReturn

        default DoubleSupplier onErrorReturn​(double fallback)
        Returns a supplier that calls this supplier. If this supplier throws any checked exception, it is discarded and the given fallback value is returned.
        Parameters:
        fallback - The value to return if this supplier throws any checked exception.
        Returns:
        A supplier that returns the fallback value if this supplier throws any checked exception.
      • of

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

        static <X extends ThrowableThrowingDoubleSupplier<X> checked​(DoubleSupplier supplier)
        Returns a supplier that calls the supplier supplier. Any unchecked exception thrown by the supplier supplier is relayed to the caller. This method allows existing DoubleSupplier instances to be used where ThrowingDoubleSupplier is expected.
        Type Parameters:
        X - The type of checked exception that can be thrown.
        Parameters:
        supplier - The supplier to call when the returned function is invoked.
        Returns:
        A supplier that wraps any checked exception in an UncheckedException.
        Throws:
        NullPointerException - If supplier is null.
      • checked

        static <X extends ThrowableThrowingDoubleSupplier<X> checked​(DoubleSupplier supplier,
                                                                       Class<X> errorType)
        Returns a supplier that calls the supplier supplier. Any UncheckedException thrown by the supplier supplier 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:
        supplier - The supplier to call when the returned supplier is invoked.
        errorType - The type of checked exception that can be thrown.
        Returns:
        A supplier that wraps any checked exception in an UncheckedException.
        Throws:
        NullPointerException - If supplier or errorType is null.