Interface Consumer<T>

Type Parameters:
T - the accepted type
All Superinterfaces:
Consumer<T>
All Known Implementing Classes:
Consumer.ExceptionLogger, SimpleDataOutput.ArrayConsumer, SimpleDataOutput.GenericArrayConsumer

public interface Consumer<T> extends Consumer<T>
An enhanced unary consumer.
Author:
Paul Ferraro
  • Field Details

  • Method Details

    • andThen

      default Consumer<T> andThen(Consumer<? super T> after)
      Specified by:
      andThen in interface Consumer<T>
    • map

      default <V> Consumer<V> map(Function<V,T> mapper)
      Returns a mapped consumer, that invokes this consumer using result of the specified function.
      Type Parameters:
      V - the mapped type
      Parameters:
      mapper - a mapping function
      Returns:
      a mapped consumer
    • empty

      static <V> Consumer<V> empty()
      Returns a consumer that performs no action.
      Type Parameters:
      V - the consumed type
      Returns:
      an empty consumer
    • close

      static <V extends AutoCloseable> Consumer<V> close()
      Returns a consumer that silently closes its object.
      Type Parameters:
      V - the auto-closeable type
      Returns:
      an closing consumer
    • log

      static Consumer<Exception> log(System.Logger.Level level)
      Returns a consumer that logs an exception at the specified level.
      Parameters:
      level - the log level
      Returns:
      an exception logging consumer
    • error

      static Consumer<Exception> error()
      Returns a consumer that logs an exception at the System.Logger.Level.ERROR level.
      Returns:
      an exception logging consumer
    • warning

      static Consumer<Exception> warning()
      Returns a consumer that logs an exception at the System.Logger.Level.WARNING level.
      Returns:
      an exception logging consumer
    • info

      static Consumer<Exception> info()
      Returns a consumer that logs an exception at the System.Logger.Level.INFO level.
      Returns:
      an exception logging consumer
    • debug

      static Consumer<Exception> debug()
      Returns a consumer that logs an exception at the System.Logger.Level.DEBUG level.
      Returns:
      an exception logging consumer
    • close

      static <V extends AutoCloseable> Consumer<V> close(Consumer<Exception> handler)
      Returns a consumer that silently closes its object using the specified exception handler.
      Type Parameters:
      V - the auto-closeable type
      Parameters:
      handler - an exception handler
      Returns:
      a silent closing consumer
    • of

      static <V> Consumer<V> of(Runnable task)
      Returns a consumer that runs the specified task, ignoring its parameter.
      Type Parameters:
      V - the ignored parameter type
      Parameters:
      task - a runnable task
      Returns:
      a consumer that runs the specified task, ignoring its parameter.
    • of

      static <V> Consumer<V> of(Iterable<Consumer<? super V>> consumers)
      Returns a composite consumer that delegates to zero or more consumers.
      Type Parameters:
      V - the consumed type
      Parameters:
      consumers - zero or more consumers
      Returns:
      a composite consumer