public abstract class MapBuilder extends Object
Map
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 calling start()
will reset the state so that more List
s may be built.
Modifier and Type | Class and Description |
---|---|
static class |
MapBuilder.Default
Default
MapBuilder implementation which builds
either HashMap or LinkedHashMap instances
(depending on JSON.Feature.PRESERVE_FIELD_ORDERING ). |
Modifier and Type | Field and Description |
---|---|
protected boolean |
_checkDups |
protected int |
_features |
protected Class<?> |
_mapType
Optional
Map implementation class, used when specific
implementation is desired. |
Modifier | Constructor and Description |
---|---|
protected |
MapBuilder(int features,
Class<?> type) |
Modifier and Type | Method and Description |
---|---|
abstract Map<String,Object> |
build() |
static MapBuilder |
defaultImpl()
Factory method for getting a blueprint instance of the default
MapBuilder implementation. |
Map<String,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(Class<?> mapImpl) |
abstract MapBuilder |
newBuilder(int features) |
abstract MapBuilder |
put(String key,
Object value) |
Map<String,Object> |
singletonMap(String key,
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() |
protected MapBuilder(int features, Class<?> type)
public static MapBuilder defaultImpl()
MapBuilder
implementation.public abstract MapBuilder newBuilder(int features)
public abstract MapBuilder newBuilder(Class<?> mapImpl)
public MapBuilder newBuilder()
public final boolean isEnabled(JSON.Feature f)
public abstract MapBuilder start()
public abstract MapBuilder put(String key, Object value)
public Map<String,Object> emptyMap() throws JSONObjectException
Default implementation simply calls:
start().build();which assumes that a builder has been constructed with
newBuilder(int)
JSONObjectException
public Map<String,Object> singletonMap(String key, Object value) throws JSONObjectException
Default implementation simply calls:
start().put(key, value).build();
JSONObjectException
Copyright © 2023 FasterXML. All rights reserved.