Interface ThrowingLongConsumer<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 ThrowingLongConsumer<X extends Throwable>
    Represents an operation that accepts a single long-valued argument and returns no result. This is a checked-exception throwing equivalent of LongConsumer.
    • Method Detail

      • accept

        void accept​(long value)
             throws X extends Throwable
        Performs this operation on the given argument.
        Parameters:
        value - The input argument.
        Throws:
        X - If an error occurs.
        X extends Throwable
      • andThen

        default ThrowingLongConsumer<X> andThen​(ThrowingLongConsumer<? extends X> after)
        Returns a composed ThrowingLongConsumer that performs, in sequence, this operation followed by the after operation. If performing either operation throws an exception, it is relayed to the caller of the composed operation. If performing this operation throws an exception, the after operation will not be performed.
        Parameters:
        after - The operation to perform after this operation.
        Returns:
        A composed ThrowingLongConsumer that performs in sequence this operation followed by the after operation.
        Throws:
        NullPointerException - If after is null.
      • onErrorThrowAsChecked

        default <E extends ThrowableThrowingLongConsumer<E> onErrorThrowAsChecked​(Function<? super X,​? extends E> errorMapper)
        Returns an operation that performs this operation on its input. Any checked exception thrown by this operation is transformed using the given error mapper, and the returned operation 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 operation.
        Returns:
        An operation that transforms any thrown checked exception.
        Throws:
        NullPointerException - If errorMapper is null.
      • onErrorThrowAsUnchecked

        default <E extends RuntimeExceptionLongConsumer onErrorThrowAsUnchecked​(Function<? super X,​? extends E> errorMapper)
        Returns an operation that performs this operation on its input. Any checked exception thrown by this operation is transformed using the given error mapper, and the returned operation 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 operation.
        Returns:
        An operation that transforms any thrown checked exception.
        Throws:
        NullPointerException - If errorMapper is null.
      • onErrorHandleChecked

        default <E extends ThrowableThrowingLongConsumer<E> onErrorHandleChecked​(ThrowingConsumer<? super X,​? extends E> errorHandler)
        Returns an operation that performs this operation on its input. Any checked exception thrown by this operation is handled by the given error handler.
        Type Parameters:
        E - The type of checked exception that can be thrown by the given error handler.
        Parameters:
        errorHandler - The operation to perform on any checked exception thrown by this operation.
        Returns:
        An operation that handles any thrown checked exception.
        Throws:
        NullPointerException - If errorHandler is null.
      • onErrorHandleUnchecked

        default LongConsumer onErrorHandleUnchecked​(Consumer<? super X> errorHandler)
        Returns an operation that performs this operation on its input. Any checked exception thrown by this operation is handled by the given error handler.
        Parameters:
        errorHandler - The operation to perform on any checked exception thrown by this operation.
        Returns:
        An operation that handles any thrown checked exception.
        Throws:
        NullPointerException - If errorHandler is null.
      • onErrorAcceptChecked

        default <E extends ThrowableThrowingLongConsumer<E> onErrorAcceptChecked​(ThrowingLongConsumer<? extends E> fallback)
        Returns an operation that performs this operation on its input. If this operation throws any checked exception, it is discarded and the given fallback operation is invoked.
        Type Parameters:
        E - The type of checked exception that can be thrown by the given fallback operation.
        Parameters:
        fallback - The operation to invoke if this operation throws any checked exception.
        Returns:
        An operation that invokes the fallback operation if this operation throws any checked exception.
        Throws:
        NullPointerException - If fallback is null.
      • onErrorAcceptUnchecked

        default LongConsumer onErrorAcceptUnchecked​(LongConsumer fallback)
        Returns an operation that performs this operation on its input. If this operation throws any checked exception, it is discarded and the given fallback operation is invoked.
        Parameters:
        fallback - The operation to invoke if this operation throws any checked exception.
        Returns:
        An operation that invokes the fallback operation if this operation throws any checked exception.
        Throws:
        NullPointerException - If fallback is null.
      • onErrorDiscard

        default LongConsumer onErrorDiscard()
        Returns an operation that performs this operation on its input. Any checked exception thrown by this operation is discarded.
        Returns:
        An operation that discards any thrown checked exception.
      • of

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

        static LongConsumer unchecked​(ThrowingLongConsumer<?> operation)
        Returns an operation that performs the operation operation to its input. Any checked exception thrown by the operation operation is wrapped in an UncheckedException.
        Parameters:
        operation - The operation to perform when the returned operation is performed.
        Returns:
        An operation that wraps any checked exception in an UncheckedException.
        Throws:
        NullPointerException - If operation is null.
      • checked

        static <X extends ThrowableThrowingLongConsumer<X> checked​(LongConsumer operation)
        Returns an operation that performs the operation operation to its input. Any checked exception thrown by the operation operation is relayed to the caller. This method allows existing LongConsumer instances to be used where ThrowingLongConsumer is expected.
        Type Parameters:
        X - The type of checked exception that can be thrown.
        Parameters:
        operation - The operation to perform when the returned operation is performed.
        Returns:
        An operation that wraps any checked exception in an UncheckedException.
        Throws:
        NullPointerException - If operation is null.
      • checked

        static <X extends ThrowableThrowingLongConsumer<X> checked​(LongConsumer operation,
                                                                     Class<X> errorType)
        Returns an operation that performs the operation operation to its input. Any UncheckedException thrown by the operation operation 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:
        operation - The operation to perform when the returned operation is performed.
        errorType - The type of checked exception that can be thrown.
        Returns:
        An operation that wraps any checked exception in an UncheckedException.
        Throws:
        NullPointerException - If operation or errorType is null.