Interface ThrowingConsumer<T,E extends Exception>

Type Parameters:
T - the type of the input to the function
E - the type of the thrown checked exception
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 ThrowingConsumer<T,E extends Exception>
Represents a function that accepts one argument and does not return any value; Function might throw a checked exception instance.
  • Method Details

    • accept

      void accept(T t) throws E
      Throws:
      E
    • unchecked

      static <T> Consumer<T> unchecked(ThrowingConsumer<T,?> consumer)
    • sneaky

      static <T> Consumer<T> sneaky(ThrowingConsumer<T,?> consumer)
      Returns a new BiConsumer instance which rethrows the checked exception using the Sneaky Throws pattern
      Returns:
      BiConsumer instance that rethrows the checked exception using the Sneaky Throws pattern
    • andThenConsume

      default ThrowingConsumer<T,E> andThenConsume(ThrowingConsumer<? super T,? extends E> after)
      Chains given ThrowingConsumer instance
      Parameters:
      after - - consumer that is chained after this instance
      Returns:
      chained Consumer instance
    • asFunction

      default ThrowingFunction<T,Void,E> asFunction()
      Returns:
      this consumer instance as a Function instance
    • uncheck

      default Consumer<T> uncheck()
      Returns:
      a Consumer instance which wraps thrown checked exception instance into a RuntimeException