public abstract static class ImmutableCollection.Builder<E>
extends java.lang.Object
ImmutableCollection
types.Modifier and Type | Field and Description |
---|---|
(package private) static int |
DEFAULT_INITIAL_CAPACITY |
Constructor and Description |
---|
Builder() |
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. |
(package private) static int |
expandedCapacity(int oldCapacity,
int minCapacity) |
static final int DEFAULT_INITIAL_CAPACITY
static int expandedCapacity(int oldCapacity, int minCapacity)
public abstract ImmutableCollection.Builder<E> add(E element)
element
to the ImmutableCollection
being built.
Note that each builder class covariantly returns its own type from this method.
element
- the element to addBuilder
instancejava.lang.NullPointerException
- if element
is nullpublic ImmutableCollection.Builder<E> add(E... elements)
elements
to the ImmutableCollection
being built.
Note that each builder class overrides this method in order to covariantly return its own type.
elements
- the elements to addBuilder
instancejava.lang.NullPointerException
- if elements
is null or contains a null elementpublic ImmutableCollection.Builder<E> addAll(java.lang.Iterable<? extends E> elements)
elements
to the ImmutableCollection
being built.
Note that each builder class overrides this method in order to covariantly return its own type.
elements
- the elements to addBuilder
instancejava.lang.NullPointerException
- if elements
is null or contains a null elementpublic ImmutableCollection.Builder<E> addAll(java.util.Iterator<? extends E> elements)
elements
to the ImmutableCollection
being built.
Note that each builder class overrides this method in order to covariantly return its own type.
elements
- the elements to addBuilder
instancejava.lang.NullPointerException
- if elements
is null or contains a null elementpublic abstract ImmutableCollection<E> build()
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.