Package 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>
Abstract base class for builders of
ImmutableCollection
types.- Since:
- 10.0
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract ImmutableCollection.Builder
<E> Addselement
to theImmutableCollection
being built.Adds each element ofelements
to theImmutableCollection
being built.Adds each element ofelements
to theImmutableCollection
being built.Adds each element ofelements
to theImmutableCollection
being built.abstract ImmutableCollection
<E> build()
Returns a newly-createdImmutableCollection
of the appropriate type, containing the elements provided to this builder.(package private) static int
expandedCapacity
(int oldCapacity, int minCapacity)
-
Field Details
-
DEFAULT_INITIAL_CAPACITY
static final int DEFAULT_INITIAL_CAPACITY- See Also:
-
-
Constructor Details
-
Builder
Builder()
-
-
Method Details
-
expandedCapacity
static int expandedCapacity(int oldCapacity, int minCapacity) -
add
Addselement
to theImmutableCollection
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:
NullPointerException
- ifelement
is null
-
add
Adds each element ofelements
to theImmutableCollection
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:
NullPointerException
- ifelements
is null or contains a null element
-
addAll
Adds each element ofelements
to theImmutableCollection
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:
NullPointerException
- ifelements
is null or contains a null element
-
addAll
Adds each element ofelements
to theImmutableCollection
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:
NullPointerException
- ifelements
is null or contains a null element
-
build
Returns a newly-createdImmutableCollection
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.
-