abstract static class ImmutableCollection.ArrayBasedBuilder<E> extends ImmutableCollection.Builder<E>
Modifier and Type | Field and Description |
---|---|
(package private) java.lang.Object[] |
contents |
(package private) int |
size |
DEFAULT_INITIAL_CAPACITY
Constructor and Description |
---|
ArrayBasedBuilder(int initialCapacity) |
Modifier and Type | Method and Description |
---|---|
ImmutableCollection.Builder<E> |
add(E... elements)
Adds each element of
elements to the ImmutableCollection
being built. |
ImmutableCollection.ArrayBasedBuilder<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. |
private void |
ensureCapacity(int minCapacity)
Expand the absolute capacity of the builder so it can accept at least
the specified number of elements without being resized.
|
addAll, build, expandedCapacity
private void ensureCapacity(int minCapacity)
public ImmutableCollection.ArrayBasedBuilder<E> add(E element)
ImmutableCollection.Builder
element
to the ImmutableCollection
being built.
Note that each builder class covariantly returns its own type from this method.
add
in class ImmutableCollection.Builder<E>
element
- the element to addBuilder
instancepublic ImmutableCollection.Builder<E> add(E... elements)
ImmutableCollection.Builder
elements
to the ImmutableCollection
being built.
Note that each builder class overrides this method in order to covariantly return its own type.
add
in class ImmutableCollection.Builder<E>
elements
- the elements to addBuilder
instancepublic ImmutableCollection.Builder<E> addAll(java.lang.Iterable<? extends E> elements)
ImmutableCollection.Builder
elements
to the ImmutableCollection
being built.
Note that each builder class overrides this method in order to covariantly return its own type.
addAll
in class ImmutableCollection.Builder<E>
elements
- the elements to addBuilder
instance