Interface Consumer<T>

Type Parameters:
T - the accepted type
All Superinterfaces:
Consumer<T>

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

    Fields
    Modifier and Type
    Field
    Description
    static final Consumer<?>
     
  • Method Summary

    Modifier and Type
    Method
    Description
    default Consumer<T>
    andThen(Consumer<? super T> after)
     
    static <V> Consumer<V>
    Returns a consumer that performs no action.
    default <V> Consumer<V>
    map(Function<V,T> mapper)
    Returns a mapped consumer, that invokes this consumer using result of the specified function.
    static <V> Consumer<V>
    of(Iterable<Consumer<? super V>> consumers)
    Returns a composite consumer that delegates to zero or more consumers.
    static <V> Consumer<V>
    of(Runnable task)
    Returns a consumer that runs the specified task, ignoring its parameter.

    Methods inherited from interface java.util.function.Consumer

    accept
  • Field Details

    • EMPTY

      static final Consumer<?> EMPTY
  • 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
    • 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