Class MapBuilder

java.lang.Object
com.fasterxml.jackson.jr.ob.api.MapBuilder
Direct Known Subclasses:
MapBuilder.Default

public abstract class MapBuilder extends Object
Helper class that is used for constructing Maps 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 Lists may be built.

  • Field Details

    • _features

      protected final int _features
    • _checkDups

      protected final boolean _checkDups
    • _mapType

      protected final Class<?> _mapType
      Optional Map implementation class, used when specific implementation is desired.
  • Constructor Details

    • MapBuilder

      protected MapBuilder(int features, Class<?> type)
  • Method Details

    • defaultImpl

      public static MapBuilder defaultImpl()
      Factory method for getting a blueprint instance of the default MapBuilder implementation.
    • newBuilder

      public abstract MapBuilder newBuilder(int features)
    • newBuilder

      public abstract MapBuilder newBuilder(Class<?> mapImpl)
    • newBuilder

      public MapBuilder newBuilder()
    • isEnabled

      public final boolean isEnabled(JSON.Feature f)
    • start

      public abstract MapBuilder start()
    • put

      public abstract MapBuilder put(String key, Object value)
    • build

      public abstract Map<String,Object> build()
    • emptyMap

      public Map<String,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 with newBuilder(int)
      Throws:
      JSONObjectException
    • singletonMap

      public Map<String,Object> singletonMap(String key, 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