Class MapperConfigBase<CFG extends ConfigFeature,T extends MapperConfigBase<CFG,T>>

java.lang.Object
tools.jackson.databind.cfg.MapperConfig<T>
tools.jackson.databind.cfg.MapperConfigBase<CFG,T>
All Implemented Interfaces:
Serializable, Snapshottable<MixInResolver>, MixInResolver
Direct Known Subclasses:
DeserializationConfig, SerializationConfig

public abstract class MapperConfigBase<CFG extends ConfigFeature,T extends MapperConfigBase<CFG,T>> extends MapperConfig<T> implements Serializable
See Also:
  • Field Details

    • EMPTY_OVERRIDE

      protected static final ConfigOverride EMPTY_OVERRIDE
    • _typeFactory

      protected final TypeFactory _typeFactory
      Specific factory used for creating JavaType instances; needed to allow modules to add more custom type handling (mostly to support types of non-Java JVM languages)
    • _classIntrospector

      protected final ClassIntrospector _classIntrospector
    • _typeResolverProvider

      protected final TypeResolverProvider _typeResolverProvider
      Since:
      3.0
    • _subtypeResolver

      protected final SubtypeResolver _subtypeResolver
      Registered concrete subtypes that can be used instead of (or in addition to) ones declared using annotations.

      Note that instances are stateful and as such may need to be copied, and may NOT be demoted down to BaseSettings.

    • _mixIns

      protected final MixInHandler _mixIns
      Mix-in annotation mappings to use, if any.
    • _rootName

      protected final PropertyName _rootName
      Explicitly defined root name to use, if any; if empty String, will disable root-name wrapping; if null, will use defaults
    • _view

      protected final Class<?> _view
      View to use for filtering out properties to serialize or deserialize. Null if none (will also be assigned null if Object.class is defined), meaning that all properties are to be included.
    • _attributes

      protected final ContextAttributes _attributes
      Contextual attributes accessible (get and set) during processing, on per-call basis.
    • _rootNames

      protected final RootNameLookup _rootNames
      Simple cache used for finding out possible root name for root name wrapping.

      Note that instances are stateful (for caching) and as such may need to be copied, and may NOT be demoted down to BaseSettings.

    • _configOverrides

      protected final ConfigOverrides _configOverrides
      Configuration overrides to apply, keyed by type of property.
    • _datatypeFeatures

      protected final DatatypeFeatures _datatypeFeatures
      Set of DatatypeFeatures enabled.
  • Constructor Details

  • Method Details

    • _withBase

      protected abstract T _withBase(BaseSettings newBase)
    • _with

      protected abstract T _with(DatatypeFeatures dtFeatures)
    • _datatypeFeatures

      protected DatatypeFeatures _datatypeFeatures()
    • with

      public final T with(DatatypeFeature feature)
      Fluent factory method that will return a configuration object instance with specified feature enabled: this may be this instance (if no changes effected), or a newly constructed instance.
    • withFeatures

      public final T withFeatures(DatatypeFeature... features)
      Fluent factory method that will return a configuration object instance with specified features enabled: this may be this instance (if no changes effected), or a newly constructed instance.
    • without

      public final T without(DatatypeFeature feature)
      Fluent factory method that will return a configuration object instance with specified feature disabled: this may be this instance (if no changes effected), or a newly constructed instance.
    • withoutFeatures

      public final T withoutFeatures(DatatypeFeature... features)
      Fluent factory method that will return a configuration object instance with specified features disabled: this may be this instance (if no changes effected), or a newly constructed instance.
    • with

      public final T with(DatatypeFeature feature, boolean state)
      Fluent factory method that will construct and return a new configuration object instance with specified features disabled.
    • with

      public abstract T with(ContextAttributes attrs)
      Method for constructing an instance that has specified contextual attributes.
    • withAttributes

      public T withAttributes(Map<?,?> attributes)
      Method for constructing an instance that has only specified attributes, removing any attributes that exist before the call.
    • withAttribute

      public T withAttribute(Object key, Object value)
      Method for constructing an instance that has specified value for attribute for given key.
    • withoutAttribute

      public T withoutAttribute(Object key)
      Method for constructing an instance that has no value for attribute for given key.
    • with

      public final T with(TypeResolverBuilder<?> trb)
      Method for constructing and returning a new instance with different TypeResolverBuilder to use.
    • with

      public T with(CacheProvider provider)
      Since:
      2.16
    • with

      public final T with(JsonNodeFactory f)
      Fluent factory method that will construct a new instance with specified JsonNodeFactory.
    • with

      public final T with(Base64Variant base64)
      Method for constructing and returning a new instance with different default Base64Variant to use with base64-encoded binary values.
    • with

      public T with(DateFormat df)
      Method for constructing and returning a new instance with different DateFormat to use.

      NOTE: non-final since SerializationConfig needs to override this

    • with

      public final T with(Locale l)
      Method for constructing and returning a new instance with different default Locale to use for formatting.
    • with

      public final T with(TimeZone tz)
      Method for constructing and returning a new instance with different default TimeZone to use for formatting of date values.
    • withRootName

      public abstract T withRootName(PropertyName rootName)
      Method for constructing and returning a new instance with different root name to use (none, if null).

      Note that when a root name is set to a non-Empty String, this will automatically force use of root element wrapping with given name. If empty String passed, will disable root name wrapping; and if null used, will instead use SerializationFeature to determine if to use wrapping, and annotation (or default name) for actual root name to use.

      Parameters:
      rootName - to use: if null, means "use default" (clear setting); if empty String ("") means that no root name wrapping is used; otherwise defines root name to use.
    • withRootName

      public T withRootName(String rootName)
    • withView

      public abstract T withView(Class<?> view)
      Method for constructing and returning a new instance with different view to use.
    • getTypeFactory

      public final TypeFactory getTypeFactory()
      Specified by:
      getTypeFactory in class MapperConfig<T extends MapperConfigBase<CFG,T>>
    • classIntrospectorInstance

      public ClassIntrospector classIntrospectorInstance()
      Description copied from class: MapperConfig
      Accessor for getting a new ClassIntrospector instance initialized for per-call usage (with possible local caching)
      Specified by:
      classIntrospectorInstance in class MapperConfig<T extends MapperConfigBase<CFG,T>>
    • getTypeResolverProvider

      public TypeResolverProvider getTypeResolverProvider()
      Specified by:
      getTypeResolverProvider in class MapperConfig<T extends MapperConfigBase<CFG,T>>
    • getSubtypeResolver

      public final SubtypeResolver getSubtypeResolver()
      Accessor for object used for finding out all reachable subtypes for supertypes; needed when a logical type name is used instead of class name (or custom scheme).
      Specified by:
      getSubtypeResolver in class MapperConfig<T extends MapperConfigBase<CFG,T>>
    • constructType

      public final JavaType constructType(Class<?> cls)
      Description copied from class: MapperConfig
      Helper method that will construct JavaType for given raw class. This is a simple short-cut for:
          getTypeFactory().constructType(cls);
      
      Specified by:
      constructType in class MapperConfig<T extends MapperConfigBase<CFG,T>>
    • constructType

      public final JavaType constructType(TypeReference<?> valueTypeRef)
      Description copied from class: MapperConfig
      Helper method that will construct JavaType for given type reference This is a simple short-cut for:
          getTypeFactory().constructType(valueTypeRef);
      
      Specified by:
      constructType in class MapperConfig<T extends MapperConfigBase<CFG,T>>
    • isEnabled

      public final boolean isEnabled(DatatypeFeature feature)
      Description copied from class: MapperConfig
      Accessor for checking whether give DatatypeFeature is enabled or not.
      Specified by:
      isEnabled in class MapperConfig<T extends MapperConfigBase<CFG,T>>
      Parameters:
      feature - Feature to check
      Returns:
      True if feature is enabled; false otherwise
    • getDatatypeFeatures

      public final DatatypeFeatures getDatatypeFeatures()
      Specified by:
      getDatatypeFeatures in class MapperConfig<T extends MapperConfigBase<CFG,T>>
    • getFullRootName

      public final PropertyName getFullRootName()
    • getActiveView

      public final Class<?> getActiveView()
      Description copied from class: MapperConfig
      Accessor for finding currently active view, if any (null if none)
      Specified by:
      getActiveView in class MapperConfig<T extends MapperConfigBase<CFG,T>>
    • getAttributes

      public final ContextAttributes getAttributes()
      Description copied from class: MapperConfig
      Method for accessing per-instance shared (baseline/default) attribute values; these are used as the basis for per-call attributes.
      Specified by:
      getAttributes in class MapperConfig<T extends MapperConfigBase<CFG,T>>
    • getConfigOverride

      public final ConfigOverride getConfigOverride(Class<?> type)
      Description copied from class: MapperConfig
      Accessor for finding ConfigOverride to use for properties of given type, if any exist; or if none, return an immutable "empty" instance with no overrides.

      Note that only directly associated override is found; no type hierarchy traversal is performed.

      Specified by:
      getConfigOverride in class MapperConfig<T extends MapperConfigBase<CFG,T>>
      Returns:
      Override object to use for the type, never null (but may be empty)
    • findConfigOverride

      public final ConfigOverride findConfigOverride(Class<?> type)
      Description copied from class: MapperConfig
      Accessor for finding ConfigOverride to use for properties of given type, if any exist; or return `null` if not.

      Note that only directly associated override is found; no type hierarchy traversal is performed.

      Specified by:
      findConfigOverride in class MapperConfig<T extends MapperConfigBase<CFG,T>>
      Returns:
      Override object to use for the type, if defined; null if none.
    • getDefaultPropertyInclusion

      public final JsonInclude.Value getDefaultPropertyInclusion()
      Description copied from class: MapperConfig
      Accessor for default property inclusion to use for serialization, used unless overridden by per-type or per-property overrides.
      Specified by:
      getDefaultPropertyInclusion in class MapperConfig<T extends MapperConfigBase<CFG,T>>
    • getDefaultPropertyInclusion

      public final JsonInclude.Value getDefaultPropertyInclusion(Class<?> baseType)
      Description copied from class: MapperConfig
      Accessor for default property inclusion to use for serialization, considering possible per-type override for given base type.
      NOTE: if no override found, defaults to value returned by MapperConfig.getDefaultPropertyInclusion().
      Specified by:
      getDefaultPropertyInclusion in class MapperConfig<T extends MapperConfigBase<CFG,T>>
    • getDefaultInclusion

      public final JsonInclude.Value getDefaultInclusion(Class<?> baseType, Class<?> propertyType)
      Description copied from class: MapperConfig
      Accessor for default property inclusion to use for serialization, considering possible per-type override for given base type and possible per-type override for given property type.
      NOTE: if no override found, defaults to value returned by MapperConfig.getDefaultPropertyInclusion().
      Specified by:
      getDefaultInclusion in class MapperConfig<T extends MapperConfigBase<CFG,T>>
      Parameters:
      baseType - Type of the instance containing the targeted property.
      propertyType - Type of the property to look up inclusion setting for.
    • getDefaultPropertyFormat

      public final JsonFormat.Value getDefaultPropertyFormat(Class<?> type)
      Description copied from class: MapperConfig
      Accessor for default format settings to use for serialization (and, to a degree deserialization), considering baseline settings and per-type defaults for given base type (if any).
      Specified by:
      getDefaultPropertyFormat in class MapperConfig<T extends MapperConfigBase<CFG,T>>
      Returns:
      (non-null) Format settings to use, possibly `JsonFormat.Value.empty()`
    • getDefaultPropertyIgnorals

      public final JsonIgnoreProperties.Value getDefaultPropertyIgnorals(Class<?> type)
      Description copied from class: MapperConfig
      Accessor for default property ignorals to use, if any, for given base type, based on config overrides settings (see MapperConfig.findConfigOverride(Class)).
      Specified by:
      getDefaultPropertyIgnorals in class MapperConfig<T extends MapperConfigBase<CFG,T>>
    • getDefaultPropertyIgnorals

      public final JsonIgnoreProperties.Value getDefaultPropertyIgnorals(Class<?> baseType, AnnotatedClass actualClass)
      Description copied from class: MapperConfig
      Helper method that may be called to see if there are property ignoral definitions from annotations (via AnnotatedClass) or through "config overrides". If both exist, config overrides have precedence over class annotations.
      Specified by:
      getDefaultPropertyIgnorals in class MapperConfig<T extends MapperConfigBase<CFG,T>>
    • getDefaultPropertyInclusions

      public final JsonIncludeProperties.Value getDefaultPropertyInclusions(Class<?> baseType, AnnotatedClass actualClass)
      Description copied from class: MapperConfig
      Helper method that may be called to see if there are property inclusion definitions from annotations (via AnnotatedClass). TODO: config override.
      Specified by:
      getDefaultPropertyInclusions in class MapperConfig<T extends MapperConfigBase<CFG,T>>
    • getDefaultVisibilityChecker

      public final VisibilityChecker getDefaultVisibilityChecker()
      Description copied from class: MapperConfig
      Accessor for object used for determining whether specific property elements (method, constructors, fields) can be auto-detected based on their visibility (access modifiers). Can be changed to allow different minimum visibility levels for auto-detection. Note that this is the global handler; individual types (classes) can further override active checker used (using JsonAutoDetect annotation)
      Specified by:
      getDefaultVisibilityChecker in class MapperConfig<T extends MapperConfigBase<CFG,T>>
    • getDefaultVisibilityChecker

      public final VisibilityChecker getDefaultVisibilityChecker(Class<?> baseType, AnnotatedClass actualClass)
      Description copied from class: MapperConfig
      Accessor for object used for determining whether specific property elements (method, constructors, fields) can be auto-detected based on their visibility (access modifiers). This is based on global defaults (as would be returned by MapperConfig.getDefaultVisibilityChecker(), but then modified by possible class annotation (see JsonAutoDetect) and/or per-type config override (see ConfigOverride.getVisibility()).
      Specified by:
      getDefaultVisibilityChecker in class MapperConfig<T extends MapperConfigBase<CFG,T>>
    • getDefaultNullHandling

      public final JsonSetter.Value getDefaultNullHandling()
      Description copied from class: MapperConfig
      Accessor for the baseline setter info used as the global baseline, not considering possible per-type overrides.
      Specified by:
      getDefaultNullHandling in class MapperConfig<T extends MapperConfigBase<CFG,T>>
      Returns:
      Global base settings; never null
    • getDefaultMergeable

      public Boolean getDefaultMergeable()
      Description copied from class: MapperConfig
      Accessor for the baseline merge info used as the global baseline, not considering possible per-type overrides.
      Specified by:
      getDefaultMergeable in class MapperConfig<T extends MapperConfigBase<CFG,T>>
      Returns:
      Global base settings, if any; `null` if none.
    • getDefaultMergeable

      public Boolean getDefaultMergeable(Class<?> baseType)
      Description copied from class: MapperConfig
      Accessor for the baseline merge info used for given type, including global defaults if no type-specific overrides defined.
      Specified by:
      getDefaultMergeable in class MapperConfig<T extends MapperConfigBase<CFG,T>>
      Returns:
      Type-specific settings (if any); global defaults (same as MapperConfig.getDefaultMergeable()) otherwise, if any defined; or `null` if neither defined
    • findRootName

      public PropertyName findRootName(DatabindContext ctxt, JavaType rootType)
      Specified by:
      findRootName in class MapperConfig<T extends MapperConfigBase<CFG,T>>
    • findRootName

      public PropertyName findRootName(DatabindContext ctxt, Class<?> rawRootType)
      Specified by:
      findRootName in class MapperConfig<T extends MapperConfigBase<CFG,T>>
    • findMixInClassFor

      public final Class<?> findMixInClassFor(Class<?> cls)
      Method that will check if there are "mix-in" classes (with mix-in annotations) for given class
      Specified by:
      findMixInClassFor in interface MixInResolver
    • hasMixIns

      public boolean hasMixIns()
      Description copied from interface: MixInResolver
      Method that may be called for optimization purposes, to see if calls to mix-in resolver may be avoided. Return value of true means that it is possible that a mix-in class will be found; false that no mix-in will ever be found. In latter case caller can avoid calls altogether.

      Note that the reason for "empty" resolvers is to use "null object" for simplifying calling code.

      Specified by:
      hasMixIns in interface MixInResolver
      Returns:
      True, if this resolver MAY have mix-ins to apply; false if not (it is "empty")
    • snapshot

      public MixInResolver snapshot()
      Description copied from interface: MixInResolver
      Method called to create a new, non-shared copy, to be used by different ObjectMapper instance, and one that should not be connected to this instance, if resolver has mutable state. If resolver is immutable may simply return `this`.
      Specified by:
      snapshot in interface MixInResolver
      Specified by:
      snapshot in interface Snapshottable<CFG extends ConfigFeature>
    • mixInCount

      public final int mixInCount()
      Test-only method -- does not reflect possibly open-ended set that external mix-in resolver might provide.
    • _createConverter

      protected Converter<Object,Object> _createConverter(Annotated annotated, Object converterDef)