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 and Description |
---|---|
protected Collection<Object> |
_current |
_collectionType, _features, EMPTY_ARRAY
Modifier | Constructor and Description |
---|---|
protected |
Default(int features,
Class<?> collImpl) |
Modifier and Type | Method and 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(Class<?> collType) |
CollectionBuilder |
newBuilder(int features) |
CollectionBuilder |
start() |
buildArray, defaultImpl, emptyArray, emptyArray, isEnabled, newBuilder, singletonArray, singletonArray, singletonCollection
protected Collection<Object> _current
protected Default(int features, Class<?> collImpl)
public CollectionBuilder newBuilder(int features)
newBuilder
in class CollectionBuilder
public CollectionBuilder newBuilder(Class<?> collType)
newBuilder
in class CollectionBuilder
public CollectionBuilder start()
start
in class CollectionBuilder
public Collection<Object> buildCollection()
CollectionBuilder
Collection
buildCollection
in class CollectionBuilder
public Object[] buildArray()
CollectionBuilder
Object[]
buildArray
in class CollectionBuilder
public CollectionBuilder add(Object value)
add
in class CollectionBuilder
public Collection<Object> emptyCollection()
CollectionBuilder
Default implementation simply calls:
start().buildCollection();
emptyCollection
in class CollectionBuilder
protected Collection<Object> _list(int initialSize)
Copyright © 2021 FasterXML. All rights reserved.