Top Description Inners Fields Constructors Methods
com.fasterxml.jackson.jr.ob.api

public abstract Class CollectionBuilder

extends Object
Class Inheritance
Known Direct Subclasses
com.fasterxml.jackson.jr.ob.api.CollectionBuilder.Default
Imports
java.lang.reflect.Array, java.util.*, com.fasterxml.jackson.jr.ob.JSON.Feature

Helper class that is used for constructing java.util.Collections 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 will be called at least once; this instance may be used and reused multiple times, as calling start will reset the state so that more Collections may be built.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
CollectionBuilder.Default

Default CollectionBuilder implementation, which uses ArrayList as the type of java.util.List to build, unless instructed otherwise.

Field Summary

Modifier and TypeField and Description
protected final Class<?>
_collectionType

Optional Collection implementation class, used when specific implementation is desired.

protected final int
protected static final Object[]

Constructor Summary

AccessConstructor and Description
protected
CollectionBuilder(int features, Class<?> collImpl)

Method Summary

Modifier and TypeMethod and Description
public abstract CollectionBuilder
add(Object value)

public Object[]
buildArray()

Alternative build method used when desired result type is Object[]

public <T> T[]
buildArray(Class<T> type)

public abstract Collection<Object>
buildCollection()

The usual build method to use for constructing Collection

public static CollectionBuilder
defaultImpl()

Factory method for getting a blueprint instance of the default CollectionBuilder implementation.

public Object[]
emptyArray()

Specialized method that is called when an empty Object[] needs to be returned.

public <T> T[]
emptyArray(Class<T> type)

public 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.

public final boolean
public abstract CollectionBuilder
newBuilder(int features)

public abstract CollectionBuilder
newBuilder(Class<?> collImpl)

public CollectionBuilder
public Object[]
singletonArray(Object value)

Specialized method that is called when a single-entry array needs to be constructed.

public <T> T[]
singletonArray(Class<?> type, T value)

public Collection<Object>
singletonCollection(Object value)

Specialized method that is called when a single-entry Collection needs to be constructed.

public abstract CollectionBuilder
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_collectionTypeback to summary
protected final Class<?> _collectionType

Optional Collection implementation class, used when specific implementation is desired.

_featuresback to summary
protected final int _features
EMPTY_ARRAYback to summary
protected static final Object[] EMPTY_ARRAY

Constructor Detail

CollectionBuilderback to summary
protected CollectionBuilder(int features, Class<?> collImpl)

Method Detail

addback to summary
public abstract CollectionBuilder add(Object value)
buildArrayback to summary
public Object[] buildArray()

Alternative build method used when desired result type is Object[]

buildArrayback to summary
public <T> T[] buildArray(Class<T> type)
Annotations
@SuppressWarnings:unchecked
buildCollectionback to summary
public abstract Collection<Object> buildCollection()

The usual build method to use for constructing Collection

defaultImplback to summary
public static CollectionBuilder defaultImpl()

Factory method for getting a blueprint instance of the default CollectionBuilder implementation.

emptyArrayback to summary
public Object[] emptyArray()

Specialized method that is called when an empty Object[] needs to be returned.

Default implementation simply returns a shared empty array instance.

emptyArrayback to summary
public <T> T[] emptyArray(Class<T> type)
Annotations
@SuppressWarnings:unchecked
emptyCollectionback to summary
public 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.

Default implementation simply calls:

  start().buildCollection();
isEnabledback to summary
public final boolean isEnabled(JSON.Feature f)
newBuilderback to summary
public abstract CollectionBuilder newBuilder(int features)
newBuilderback to summary
public abstract CollectionBuilder newBuilder(Class<?> collImpl)
newBuilderback to summary
public CollectionBuilder newBuilder()
singletonArrayback to summary
public Object[] singletonArray(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 }
singletonArrayback to summary
public <T> T[] singletonArray(Class<?> type, T value)
singletonCollectionback to summary
public Collection<Object> singletonCollection(Object value)

Specialized method that is called when a single-entry Collection needs to be constructed.

Default implementation simply calls:

  start().add(value).buildCollection();
startback to summary
public abstract CollectionBuilder start()
com.fasterxml.jackson.jr.ob.api back to summary

public Class CollectionBuilder.Default

extends CollectionBuilder
Class Inheritance

Default CollectionBuilder implementation, which uses ArrayList as the type of java.util.List to build, unless instructed otherwise.

When sub-classing to use different underlying mutable java.util.List type, you need to sub-class following methods:

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.

Field Summary

Modifier and TypeField and Description
protected Collection<Object>
Inherited from com.fasterxml.jackson.jr.ob.api.CollectionBuilder:
_collectionType_featuresEMPTY_ARRAY

Constructor Summary

AccessConstructor and Description
protected
Default(int features, Class<?> collImpl)

Method Summary

Modifier and TypeMethod and Description
protected Collection<Object>
_list(int initialSize)

Overridable factory method for constructing underlying List.

public CollectionBuilder
public Object[]
buildArray()

Overrides com.fasterxml.jackson.jr.ob.api.CollectionBuilder.buildArray.

Alternative build method used when desired result type is Object[]

public Collection<Object>
buildCollection()

Implements abstract com.fasterxml.jackson.jr.ob.api.CollectionBuilder.buildCollection.

The usual build method to use for constructing Collection

public Collection<Object>
emptyCollection()

Overrides com.fasterxml.jackson.jr.ob.api.CollectionBuilder.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.

public CollectionBuilder
public CollectionBuilder
public CollectionBuilder
Inherited from com.fasterxml.jackson.jr.ob.api.CollectionBuilder:
buildArraydefaultImplemptyArrayemptyArrayisEnablednewBuildersingletonArraysingletonArraysingletonCollection

Field Detail

_currentback to summary
protected Collection<Object> _current

Constructor Detail

Defaultback to summary
protected Default(int features, Class<?> collImpl)

Method Detail

_listback to summary
protected Collection<Object> _list(int initialSize)

Overridable factory method for constructing underlying List.

addback to summary
public CollectionBuilder add(Object value)

Implements abstract com.fasterxml.jackson.jr.ob.api.CollectionBuilder.add.

Annotations
@Override
buildArrayback to summary
public Object[] buildArray()

Overrides com.fasterxml.jackson.jr.ob.api.CollectionBuilder.buildArray.

Doc from com.fasterxml.jackson.jr.ob.api.CollectionBuilder.buildArray.

Alternative build method used when desired result type is Object[]

Annotations
@Override
buildCollectionback to summary
public Collection<Object> buildCollection()

Implements abstract com.fasterxml.jackson.jr.ob.api.CollectionBuilder.buildCollection.

Doc from com.fasterxml.jackson.jr.ob.api.CollectionBuilder.buildCollection.

The usual build method to use for constructing Collection

Annotations
@Override
emptyCollectionback to summary
public Collection<Object> emptyCollection()

Overrides com.fasterxml.jackson.jr.ob.api.CollectionBuilder.emptyCollection.

Doc from com.fasterxml.jackson.jr.ob.api.CollectionBuilder.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();
Annotations
@Override
newBuilderback to summary
public CollectionBuilder newBuilder(int features)

Implements abstract com.fasterxml.jackson.jr.ob.api.CollectionBuilder.newBuilder.

Annotations
@Override
newBuilderback to summary
public CollectionBuilder newBuilder(Class<?> collType)

Implements abstract com.fasterxml.jackson.jr.ob.api.CollectionBuilder.newBuilder.

Annotations
@Override
startback to summary
public CollectionBuilder start()

Implements abstract com.fasterxml.jackson.jr.ob.api.CollectionBuilder.start.

Annotations
@Override