Class CollectionBuilder

java.lang.Object
com.globalmentor.collections.CollectionBuilder

public class CollectionBuilder extends Object
Utility methods for building collections using a fluent interface.
Author:
Garret Wilson
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <E, C extends Collection<E>>
    C
    addAll(C collection, E... elements)
    Adds all of the specified elements to the specified collection and returns the given collection.
    static <E, C extends Collection<E>>
    C
    addAll(C collection, Iterable<? extends E> iterable)
    Appends the contents of an iterable to a collection.
    static <E, C extends Collection<E>>
    C
    addAll(C collection, Iterator<? extends E> iterator)
    Adds all of the elements specified by the given iterator to the specified collection and returns the given collection.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CollectionBuilder

      public CollectionBuilder()
  • Method Details

    • addAll

      public static <E, C extends Collection<E>> C addAll(C collection, Iterable<? extends E> iterable)
      Appends the contents of an iterable to a collection. This method functions identical to List.addAll(Collection), except that this method returns the given collection.
      Type Parameters:
      E - The type of element contained in the collection.
      C - The type of collection.
      Parameters:
      collection - The collection to which objects will be added.
      iterable - The source of the added objects.
      Returns:
      The given collection.
    • addAll

      public static <E, C extends Collection<E>> C addAll(C collection, Iterator<? extends E> iterator)
      Adds all of the elements specified by the given iterator to the specified collection and returns the given collection.
      Type Parameters:
      E - The type of element contained in the collection.
      C - The type of collection.
      Parameters:
      collection - The collection to which objects will be added.
      iterator - The source of the added objects.
      Returns:
      The given collection.
    • addAll

      public static <E, C extends Collection<E>> C addAll(C collection, E... elements)
      Adds all of the specified elements to the specified collection and returns the given collection.
      Type Parameters:
      E - The type of element contained in the collection.
      C - The type of collection.
      Parameters:
      collection - The collection to which objects will be added.
      elements - The source of the added objects.
      Returns:
      The given collection.