Interface ConsumerEx<T>

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 ConsumerEx<T>
Represents a Consumer capable of throwing exceptions
  • Method Details

    • accept

      void accept(T t) throws Exception
      Throws:
      Exception
    • of

      static <T> ConsumerEx<T> of(Consumer<T> uncheckedFn)
      Creates a ConsumerEx out of Consumer

      If given consumer throws UncheckedException, its cause will be propagated

      Parameters:
      uncheckedFn - original Consumer
      Returns:
      a consumer capable of throwing exceptions
    • uncheckedOf

      static <T> Consumer<T> uncheckedOf(ConsumerEx<T> checkedFn)
      Creates a Consumer out of ConsumerEx

      If given consumer throws a checked exception, it will be wrapped into UncheckedException and rethrown

      Unchecked exceptions will be handled by thread's FatalErrorHandler

      Parameters:
      checkedFn - original ConsumerEx
      Returns:
      a consumer