Interface BiConsumerWithException<T,U,E extends Exception>

    • Method Detail

      • andThen

        default BiConsumerWithException<T,U,EandThen​(BiConsumerWithException<? super T,? super U,? extends E> after)
        Returns a composed BiConsumerWithException 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 BiConsumerWithException that performs in sequence this operation followed by the after operation
        Throws:
        NullPointerException - if after is null
        See Also:
        BiConsumer.andThen(BiConsumer)
      • failing

        static <T,U,E extends ExceptionBiConsumerWithException<T,U,E> failing​(Supplier<E> exceptionBuilder)
        Returns a BiConsumerWithException that always throw exception.
        Type Parameters:
        T - the type of the first argument to the operation
        U - the type of the second argument to the operation
        E - the type of the potential exception of the operation
        Parameters:
        exceptionBuilder - the supplier to create the exception
        Returns:
        an operation that always throw exception
      • unchecked

        static <T,U,E extends ExceptionBiConsumer<T,U> unchecked​(BiConsumerWithException<T,U,E> consumer)
        Converts a BiConsumerWithException to a BiConsumer that wraps exception to RuntimeException.

        For example :

         BiConsumerWithException<String, String, IOException> consumerThrowingException = ...;
        
         BiConsumer<String, String> consumerThrowingRuntimeException =
           ConsumerWithException.unchecked(consumerThrowingException);
        
         myMap.forEach(consumerThrowingRuntimeException);
         
        In case of exception inside consumerThrowingRuntimeException an instance of WrappedException with the original exception as cause will be thrown.
        Type Parameters:
        T - the type of the first argument to the operation
        U - the type of the second argument to the operation
        E - the type of the potential exception of the operation
        Parameters:
        consumer - to be unchecked
        Returns:
        the unchecked exception
        Throws:
        NullPointerException - if consumer is null
        See Also:
        uncheck(), unchecked(BiConsumerWithException, Function)
      • unchecked

        static <T,U,E extends ExceptionBiConsumer<T,U> unchecked​(BiConsumerWithException<T,U,E> consumer,
                                                                   Function<Exception,RuntimeException> exceptionMapper)
        Converts a BiConsumerWithException to a BiConsumer that wraps exception to RuntimeException by using the provided mapping function.

        For example :

         BiConsumerWithException<String, String, IOException> consumerThrowingException = ...;
        
         BiConsumer<String, String> consumerThrowingRuntimeException =
           ConsumerWithException.unchecked(
             consumerThrowingException,
             IllegalArgumentException::new);
        
         myMap.forEach(consumerThrowingRuntimeException)
         
        In case of exception inside consumerThrowingRuntimeException an instance of IllegalArgumentException with the original exception as cause will be thrown.
        Type Parameters:
        T - the type of the first argument to the operation
        U - the type of the second argument to the operation
        E - the type of the potential exception of the operation
        Parameters:
        consumer - the be unchecked
        exceptionMapper - a function to convert the exception to the runtime exception.
        Returns:
        the unchecked exception
        Throws:
        NullPointerException - if consumer or exceptionMapper is null
        See Also:
        uncheck(), unchecked(BiConsumerWithException)
      • lifted

        static <T,U,E extends ExceptionBiConsumer<T,U> lifted​(BiConsumerWithException<T,U,E> consumer)
        Converts a BiConsumerWithException to a lifted BiConsumer ignoring exception.

        For example :

         BiConsumerWithException<String, String, IOException> consumerThrowingException = ...;
        
         BiConsumer<String, String> consumerThrowingRuntimeException =
           ConsumerWithException.lifted(consumerThrowingException);
        
         myMap.forEach(consumerThrowingRuntimeException);
         
        In case of exception inside consumerThrowingRuntimeException the exception will be ignored.
        Type Parameters:
        T - the type of the first argument to the operation
        U - the type of the second argument to the operation
        E - the type of the potential exception of the operation
        Parameters:
        consumer - to be lifted
        Returns:
        the lifted operation
        Throws:
        NullPointerException - if consumer is null
        See Also:
        NoReturnExceptionHandlerSupport.lift()
      • ignored

        static <T,U,E extends ExceptionBiConsumer<T,U> ignored​(BiConsumerWithException<T,U,E> consumer)
        Converts a BiConsumerWithException to a lifted BiConsumer ignoring exception.

        For example :

         BiConsumerWithException<String, String, IOException> consumerThrowingException = ...;
        
         BiConsumer<String, String> consumerThrowingRuntimeException =
           ConsumerWithException.ignored(consumerThrowingException);
        
         myMap.forEach(consumerThrowingRuntimeException);
         
        In case of exception inside consumerThrowingRuntimeException the exception will be ignored.
        Type Parameters:
        T - the type of the first argument to the operation
        U - the type of the second argument to the operation
        E - the type of the potential exception of the operation
        Parameters:
        consumer - to be lifted
        Returns:
        the lifted operation
        Throws:
        NullPointerException - if consumer is null
        See Also:
        ignore()
      • staged

        static <T,U,E extends ExceptionBiFunction<T,U,CompletionStage<Void>> staged​(BiConsumerWithException<T,U,E> consumer)
        Converts a BiConsumerWithException to a staged BiFunction.
        Type Parameters:
        T - the type of the first argument to the operation
        U - the type of the second argument to the operation
        E - the type of the potential exception
        Parameters:
        consumer - to be staged
        Returns:
        the staged operation
        Throws:
        NullPointerException - if consumer is null
        Since:
        1.1.0
      • asBiFunction

        static <T,U,R,E extends ExceptionBiFunctionWithException<T,U,R,E> asBiFunction​(BiConsumerWithException<T,U,E> consumer)
        Converts a BiConsumerWithException to a BiFunctionWithException returning null.
        Type Parameters:
        T - the type of the first argument to the operation
        U - the type of the second argument to the operation
        R - the type of the return value of the function
        E - the type of the potential exception of the operation
        Parameters:
        consumer - to be converter
        Returns:
        the function
        Throws:
        NullPointerException - if consumer is null
      • asBiFunction

        default <R> BiFunctionWithException<T,U,R,EasBiFunction()
        Converts a BiConsumerWithException to a BiFunctionWithException returning null.
        Type Parameters:
        R - the type of the return value of the function
        Returns:
        the function
        Since:
        1.2.0