public static class CollectionBuilder.Default extends CollectionBuilder
CollectionBuilder implementation, which uses ArrayList
as the type of List to build, unless instructed otherwise.
When sub-classing to use different underlying mutable List
type, you need to sub-class following methods:
newBuilder(int): factory method for constructing new builder instance
_list(int): factory method for constructing List to build
If constructing builders that use different approaches (like, say, produce
immutable Guava Lists), you may need to override more methods; or perhaps
just extend basic CollectionBuilder.
CollectionBuilder.Default| Modifier and Type | Field | Description |
|---|---|---|
protected Collection<Object> |
_current |
_collectionType, _features, EMPTY_ARRAY| Modifier | Constructor | Description |
|---|---|---|
protected |
Default(int features,
Class<?> collImpl) |
| Modifier and Type | Method | Description |
|---|---|---|
protected Collection<Object> |
_list(int initialSize) |
Overridable factory method for constructing underlying List.
|
CollectionBuilder |
add(Object value) |
|
Object[] |
buildArray() |
Alternative build method used when desired result type is
Object[] |
Collection<Object> |
buildCollection() |
The usual build method to use for constructing
Collection |
Collection<Object> |
emptyCollection() |
Specialized method that is called when an empty Collection needs to
be constructed; this may be a new Collection, or an immutable shared
one, depending on implementation.
|
CollectionBuilder |
newBuilder(int features) |
|
CollectionBuilder |
newBuilder(Class<?> collType) |
|
CollectionBuilder |
start() |
buildArray, defaultImpl, emptyArray, emptyArray, isEnabled, newBuilder, singletonArray, singletonArray, singletonCollectionprotected Collection<Object> _current
protected Default(int features,
Class<?> collImpl)
public CollectionBuilder newBuilder(int features)
newBuilder in class CollectionBuilderpublic CollectionBuilder newBuilder(Class<?> collType)
newBuilder in class CollectionBuilderpublic CollectionBuilder start()
start in class CollectionBuilderpublic Collection<Object> buildCollection()
CollectionBuilderCollectionbuildCollection in class CollectionBuilderpublic Object[] buildArray()
CollectionBuilderObject[]buildArray in class CollectionBuilderpublic CollectionBuilder add(Object value)
add in class CollectionBuilderpublic Collection<Object> emptyCollection()
CollectionBuilderDefault implementation simply calls:
start().buildCollection();
emptyCollection in class CollectionBuilderprotected Collection<Object> _list(int initialSize)
Copyright © 2018. All rights reserved.