Interface ThrowingObjLongConsumer<T,​X extends Throwable>

  • Type Parameters:
    T - The type of the object argument to the operation.
    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 ThrowingObjLongConsumer<T,​X extends Throwable>
    Represents an operation that accepts an object-valued and a long-valued argument, and returns no result. This is a checked-exception throwing equivalent of ObjLongConsumer.
    • Method Detail

      • accept

        void accept​(T t,
                    long value)
             throws X extends Throwable
        Performs this operation on the given arguments.
        Parameters:
        t - The first input argument.
        value - The second input argument.
        Throws:
        X - If an error occurs.
        X extends Throwable
      • onErrorThrowAsChecked

        default <E extends ThrowableThrowingObjLongConsumer<T,​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 RuntimeExceptionObjLongConsumer<T> 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 ThrowableThrowingObjLongConsumer<T,​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 ObjLongConsumer<T> 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 ThrowableThrowingObjLongConsumer<T,​E> onErrorAcceptChecked​(ThrowingObjLongConsumer<? super T,​? 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 ObjLongConsumer<T> onErrorAcceptUnchecked​(ObjLongConsumer<? super T> 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 ObjLongConsumer<T> 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 <T,​X extends ThrowableThrowingObjLongConsumer<T,​X> of​(ThrowingObjLongConsumer<T,​X> operation)
        Factory method for turning ThrowingObjLongConsumer-shaped lambdas into ThrowingObjLongConsumers.
        Type Parameters:
        T - The type of the object argument to the operation.
        X - The type of checked exception that can be thrown.
        Parameters:
        operation - The lambda to return as ThrowingObjLongConsumer.
        Returns:
        The given lambda as a ThrowingObjLongConsumer.
        Throws:
        NullPointerException - If operation is null.
      • unchecked

        static <T> ObjLongConsumer<T> unchecked​(ThrowingObjLongConsumer<? super T,​?> 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.
        Type Parameters:
        T - The type of the object argument to the operation.
        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 <T,​X extends ThrowableThrowingObjLongConsumer<T,​X> checked​(ObjLongConsumer<? super T> 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 ObjLongConsumer instances to be used where ThrowingObjLongConsumer is expected.
        Type Parameters:
        T - The type of the object argument to the operation.
        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 <T,​X extends ThrowableThrowingObjLongConsumer<T,​X> checked​(ObjLongConsumer<? super T> 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:
        T - The type of the object argument to the operation.
        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.