Interface ThrowingConsumer<T,​E extends Throwable>

  • Type Parameters:
    T - type of the consumed elements.
    E - type of the exception thrown.
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @Public
    @FunctionalInterface
    public interface ThrowingConsumer<T,​E extends Throwable>
    This interface is basically Java's Consumer interface enhanced with the ability to throw an exception.
    • Method Detail

      • accept

        void accept​(T t)
             throws E extends Throwable
        Performs this operation on the given argument.
        Parameters:
        t - the input argument
        Throws:
        E - on errors during consumption
        E extends Throwable
      • unchecked

        static <A> Consumer<A> unchecked​(ThrowingConsumer<A,​?> throwingConsumer)
        Convert a ThrowingConsumer into a Consumer.
        Type Parameters:
        A - input type
        Parameters:
        throwingConsumer - Consumer with exception to convert into a Consumer.
        Returns:
        Consumer which rethrows all checked exceptions as unchecked.