Package com.fasterxml.jackson.jr.ob.api
Class CollectionBuilder
- java.lang.Object
-
- com.fasterxml.jackson.jr.ob.api.CollectionBuilder
-
- Direct Known Subclasses:
CollectionBuilder.Default
public abstract class CollectionBuilder extends java.lang.Object
Helper class that is used for constructingCollection
s to map JSON Array values in.Objects server both as "factories" for creating new builders (blueprint style), and as actual builders. For each distinct read operation,
newBuilder(int)
will be called at least once; this instance may be used and reused multiple times, as callingstart()
will reset the state so that moreCollection
s may be built.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CollectionBuilder.Default
DefaultCollectionBuilder
implementation, which usesArrayList
as the type ofList
to build, unless instructed otherwise.
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Class<?>
_collectionType
OptionalCollection
implementation class, used when specific implementation is desired.protected int
_features
protected static java.lang.Object[]
EMPTY_ARRAY
-
Constructor Summary
Constructors Modifier Constructor Description protected
CollectionBuilder(int features, java.lang.Class<?> collImpl)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract CollectionBuilder
add(java.lang.Object value)
java.lang.Object[]
buildArray()
Alternative build method used when desired result type isObject[]
<T> T[]
buildArray(java.lang.Class<T> type)
abstract java.util.Collection<java.lang.Object>
buildCollection()
The usual build method to use for constructingCollection
static CollectionBuilder
defaultImpl()
Factory method for getting a blueprint instance of the defaultCollectionBuilder
implementation.java.lang.Object[]
emptyArray()
Specialized method that is called when an emptyObject[]
needs to be returned.<T> T[]
emptyArray(java.lang.Class<T> type)
java.util.Collection<java.lang.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.boolean
isEnabled(JSON.Feature f)
CollectionBuilder
newBuilder()
abstract CollectionBuilder
newBuilder(int features)
abstract CollectionBuilder
newBuilder(java.lang.Class<?> collImpl)
<T> T[]
singletonArray(java.lang.Class<?> type, T value)
java.lang.Object[]
singletonArray(java.lang.Object value)
Specialized method that is called when a single-entry array needs to be constructed.java.util.Collection<java.lang.Object>
singletonCollection(java.lang.Object value)
Specialized method that is called when a single-entry Collection needs to be constructed.abstract CollectionBuilder
start()
-
-
-
Method Detail
-
defaultImpl
public static CollectionBuilder defaultImpl()
Factory method for getting a blueprint instance of the defaultCollectionBuilder
implementation.
-
newBuilder
public abstract CollectionBuilder newBuilder(int features)
-
newBuilder
public abstract CollectionBuilder newBuilder(java.lang.Class<?> collImpl)
-
newBuilder
public CollectionBuilder newBuilder()
-
isEnabled
public final boolean isEnabled(JSON.Feature f)
-
start
public abstract CollectionBuilder start()
-
add
public abstract CollectionBuilder add(java.lang.Object value)
-
buildCollection
public abstract java.util.Collection<java.lang.Object> buildCollection()
The usual build method to use for constructingCollection
-
buildArray
public java.lang.Object[] buildArray()
Alternative build method used when desired result type isObject[]
-
buildArray
public <T> T[] buildArray(java.lang.Class<T> type)
-
emptyCollection
public java.util.Collection<java.lang.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.Default implementation simply calls:
start().buildCollection();
-
emptyArray
public java.lang.Object[] emptyArray()
Specialized method that is called when an emptyObject[]
needs to be returned.Default implementation simply returns a shared empty array instance.
-
emptyArray
public <T> T[] emptyArray(java.lang.Class<T> type)
-
singletonCollection
public java.util.Collection<java.lang.Object> singletonCollection(java.lang.Object value)
Specialized method that is called when a single-entry Collection needs to be constructed.Default implementation simply calls:
start().add(value).buildCollection();
-
singletonArray
public java.lang.Object[] singletonArray(java.lang.Object value)
Specialized method that is called when a single-entry array needs to be constructed.Default implementation simply returns equivalent of:
new Object[] { value }
-
singletonArray
public <T> T[] singletonArray(java.lang.Class<?> type, T value)
-
-