ImmutableCollection.Builder
Date: 2016-05-24

com.google.common.collect

## Class ImmutableCollection.Builder<E>

- java.lang.Object
- - com.google.common.collect.ImmutableCollection.Builder<E>

- Direct Known Subclasses:
    ImmutableList.Builder, ImmutableMultiset.Builder, ImmutableSet.Builder
  Enclosing class:
    ImmutableCollection<E>

      public abstract static class ImmutableCollection.Builder<E>
      extends java.lang.Object

  Abstract base class for builders of `ImmutableCollection` types.
  Since:
    10.0

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `ImmutableCollection.Builder<E>` | `add(E... elements)` Adds each element of `elements` to the `ImmutableCollection` being built.
    `abstract ImmutableCollection.Builder<E>` | `add(E element)` Adds `element` to the `ImmutableCollection` being built.
    `ImmutableCollection.Builder<E>` | `addAll(java.lang.Iterable<? extends E> elements)` Adds each element of `elements` to the `ImmutableCollection` being built.
    `ImmutableCollection.Builder<E>` | `addAll(java.util.Iterator<? extends E> elements)` Adds each element of `elements` to the `ImmutableCollection` being built.
    `abstract ImmutableCollection<E>` | `build()` Returns a newly-created `ImmutableCollection` of the appropriate type, containing the elements provided to this builder.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### add

          public abstract ImmutableCollection.Builder<E> add(E element)

      Adds `element` to the `ImmutableCollection` being built.

      Note that each builder class covariantly returns its own type from this method.

      Parameters:
        `element` - the element to add
      Returns:
        this `Builder` instance
      Throws:
        `java.lang.NullPointerException` - if `element` is null

    - #### add

          public ImmutableCollection.Builder<E> add(E... elements)

      Adds each element of `elements` to the `ImmutableCollection` being built.

      Note that each builder class overrides this method in order to covariantly return its own type.

      Parameters:
        `elements` - the elements to add
      Returns:
        this `Builder` instance
      Throws:
        `java.lang.NullPointerException` - if `elements` is null or contains a null element

    - #### addAll

          public ImmutableCollection.Builder<E> addAll(java.lang.Iterable<? extends E> elements)

      Adds each element of `elements` to the `ImmutableCollection` being built.

      Note that each builder class overrides this method in order to covariantly return its own type.

      Parameters:
        `elements` - the elements to add
      Returns:
        this `Builder` instance
      Throws:
        `java.lang.NullPointerException` - if `elements` is null or contains a null element

    - #### addAll

          public ImmutableCollection.Builder<E> addAll(java.util.Iterator<? extends E> elements)

      Adds each element of `elements` to the `ImmutableCollection` being built.

      Note that each builder class overrides this method in order to covariantly return its own type.

      Parameters:
        `elements` - the elements to add
      Returns:
        this `Builder` instance
      Throws:
        `java.lang.NullPointerException` - if `elements` is null or contains a null element

    - #### build

          public abstract ImmutableCollection<E> build()

      Returns a newly-created `ImmutableCollection` of the appropriate type, containing the elements provided to this builder.

      Note that each builder class covariantly returns the appropriate type of `ImmutableCollection` from this method.