com.fasterxml.jackson.jr.ob.impl.MapBuilder Maven / Gradle / Ivy
package com.fasterxml.jackson.jr.ob.impl;
import java.util.*;
import com.fasterxml.jackson.jr.ob.JSON;
import com.fasterxml.jackson.jr.ob.JSON.Feature;
/**
* Helper class that is used for constructing {@link java.util.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,
* {@link #newBuilder} will be called at least once; this instance
* may be used and reused multiple times, as calling {@link #start}
* will reset the state so that more {@link List}s may be built.
*/
public abstract class MapBuilder
{
protected final int _features;
/**
* Optional {@link Map} implementation class, used when specific
* implementation is desired.
*/
protected final Class> _mapType;
protected MapBuilder(int features, Class> type) {
_features = features;
_mapType = type;
}
/**
* Factory method for getting a blueprint instance of the default
* {@link MapBuilder} implementation.
*/
public static MapBuilder defaultImpl() {
return new Default(0, null);
}
public abstract MapBuilder newBuilder(int features);
public abstract MapBuilder newBuilder(Class> mapImpl);
public MapBuilder newBuilder() {
return newBuilder(_features);
}
public final boolean isEnabled(JSON.Feature f) {
return f.isEnabled(_features);
}
public abstract MapBuilder start();
public abstract MapBuilder put(Object key, Object value);
public abstract Map