Interface IThrowingBiConsumer<T,​U>

  • Type Parameters:
    T - the type of the first input to the operation
    U - the type of the second input to the operation
    All Superinterfaces:
    BiConsumer<T,​U>
    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 IThrowingBiConsumer<T,​U>
    extends BiConsumer<T,​U>
    A BiConsumer that may throw a checked exception.

    Represents an operation that accepts a two input argument and returns no result. Unlike most other functional interfaces, BiConsumer is expected to operate via side effects.

    This is a functional interface whose functional method is tryAccept(Object, Object).

    Since:
    8.3.0
    Author:
    XIMA MEDIA GmbH
    • Method Detail

      • accept

        default void accept​(T t,
                            U u)
        Specified by:
        accept in interface BiConsumer<T,​U>
      • tryAccept

        void tryAccept​(T t,
                       U u)
                throws Exception
        Performs this operation on the given argument.
        Parameters:
        t - the first input argument
        u - the second input argument
        Throws:
        Exception - When this operation fails.
      • of

        static <T,​U> IThrowingBiConsumer<T,​U> of​(IThrowingBiConsumer<T,​U> biConsumer)
        Returns the given bi-consumer, for improved variable inference. Sometimes you need to create local variables and assign them to a new lambda. This does not work well with variable inference, as Java cannot infer the type of an anonymous lambda. This utility method lets you write slightly more readable code like this:
         final var biConsumer = IThrowingBiConsumer.of(() -> ...);
        
         
        Type Parameters:
        T - the type of the first input to the operation
        U - the type of the second input to the operation
        Parameters:
        biConsumer - Bi-consumer to return.
        Returns:
        The given bi-consumer.
      • throwingConsumer

        static <T,​U> IThrowingBiConsumer<T,​U> throwingConsumer​(IThrowingBiConsumer<T,​U> biConsumer)
        Returns the given bi-consumer, for improved variable inference. Sometimes you need to create local variables and assign them to a new lambda. This does not work well with variable inference, as Java cannot infer the type of an anonymous lambda. This utility method lets you write slightly more readable code like this:
         final var biConsumer = throwingBiConsumer(() -> ...);
        
         
        Type Parameters:
        T - the type of the first input to the operation
        U - the type of the second input to the operation
        Parameters:
        biConsumer - Consumer to return.
        Returns:
        The given consumer.