Package com.fasterxml.jackson.jr.ob.api
Class MapBuilder
- java.lang.Object
-
- com.fasterxml.jackson.jr.ob.api.MapBuilder
-
- Direct Known Subclasses:
MapBuilder.Default
public abstract class MapBuilder extends java.lang.Object
Helper class that is used for constructingMap
s to map JSON Object 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 moreList
s may be built.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MapBuilder.Default
DefaultMapBuilder
implementation which builds eitherHashMap
orLinkedHashMap
instances (depending onJSON.Feature.PRESERVE_FIELD_ORDERING
).
-
Field Summary
Fields Modifier and Type Field Description protected boolean
_checkDups
protected int
_features
protected java.lang.Class<?>
_mapType
OptionalMap
implementation class, used when specific implementation is desired.
-
Constructor Summary
Constructors Modifier Constructor Description protected
MapBuilder(int features, java.lang.Class<?> type)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract java.util.Map<java.lang.String,java.lang.Object>
build()
static MapBuilder
defaultImpl()
Factory method for getting a blueprint instance of the defaultMapBuilder
implementation.java.util.Map<java.lang.String,java.lang.Object>
emptyMap()
Specialized method that is called when an empty list needs to be constructed; this may be a new list, or an immutable shared List, depending on implementation.boolean
isEnabled(JSON.Feature f)
MapBuilder
newBuilder()
abstract MapBuilder
newBuilder(int features)
abstract MapBuilder
newBuilder(java.lang.Class<?> mapImpl)
abstract MapBuilder
put(java.lang.String key, java.lang.Object value)
java.util.Map<java.lang.String,java.lang.Object>
singletonMap(java.lang.String key, java.lang.Object value)
Specialized method that is called when an empty list needs to be constructed; this may be a new list, or an immutable shared List, depending on implementation.abstract MapBuilder
start()
-
-
-
Method Detail
-
defaultImpl
public static MapBuilder defaultImpl()
Factory method for getting a blueprint instance of the defaultMapBuilder
implementation.
-
newBuilder
public abstract MapBuilder newBuilder(int features)
-
newBuilder
public abstract MapBuilder newBuilder(java.lang.Class<?> mapImpl)
-
newBuilder
public MapBuilder newBuilder()
-
isEnabled
public final boolean isEnabled(JSON.Feature f)
-
start
public abstract MapBuilder start()
-
put
public abstract MapBuilder put(java.lang.String key, java.lang.Object value)
-
build
public abstract java.util.Map<java.lang.String,java.lang.Object> build()
-
emptyMap
public java.util.Map<java.lang.String,java.lang.Object> emptyMap() throws JSONObjectException
Specialized method that is called when an empty list needs to be constructed; this may be a new list, or an immutable shared List, depending on implementation.Default implementation simply calls:
start().build();
which assumes that a builder has been constructed withnewBuilder(int)
- Throws:
JSONObjectException
-
singletonMap
public java.util.Map<java.lang.String,java.lang.Object> singletonMap(java.lang.String key, java.lang.Object value) throws JSONObjectException
Specialized method that is called when an empty list needs to be constructed; this may be a new list, or an immutable shared List, depending on implementation.Default implementation simply calls:
start().put(key, value).build();
- Throws:
JSONObjectException
-
-