Class CollectingConsumer<E>

java.lang.Object
org.soliscode.test.util.CollectingConsumer<E>
Type Parameters:
E - The type of the parameter for the accept method.
All Implemented Interfaces:
Consumer<E>

public class CollectingConsumer<E> extends Object implements Consumer<E>
Collects the arguments for each call to the accept() method.
Since:
1.0
Author:
evanbergstrom
  • Constructor Details

    • CollectingConsumer

      public CollectingConsumer()
  • Method Details

    • accept

      public void accept(E e)
      Collects the argument provided to this method.
      Specified by:
      accept in interface Consumer<E>
      Parameters:
      e - The argument to collect.
    • toList

      public List<E> toList()
      Returns all the arguments provided to the accept method in order.
      Returns:
      A List of the arguments to the accept method.
    • toSet

      public Set<E> toSet()
      Returns all the arguments provided to the accept method.
      Returns:
      A Set of the arguments to the accept method.