Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.fasterxml.jackson.databind;
  
  import java.util.*;
  
Object that contains baseline configuration for deserialization process. An instance is owned by ObjectMapper, which passes an immutable instance to be used for deserialization process.

Note that instances are considered immutable and as such no copies should need to be created for sharing; all copying is done with "fluent factory" methods. Note also that unlike with Jackson 1, these instances can not be assigned to ObjectMapper; in fact, application code should rarely interact directly with these instance (unlike core Jackson code)

 
 public final class DeserializationConfig
     implements java.io.Serializable // since 2.1
 {
     // for 2.1.0
     private static final long serialVersionUID = -4227480407273773599L;

    
Set of features enabled; actual type (kind of features) depends on sub-classes.
 
     protected final int _deserFeatures;

    
Linked list that contains all registered problem handlers. Implementation as front-added linked list allows for sharing of the list (tail) without copying the list.
 
     protected final LinkedNode<DeserializationProblemHandler_problemHandlers;
    
    
Factory used for constructing JsonNode instances.
 
     protected final JsonNodeFactory _nodeFactory;
     
     /*
     /**********************************************************
     /* Life-cycle, constructors
     /**********************************************************
      */

    
Constructor used by ObjectMapper to create default configuration object instance.
 
     public DeserializationConfig(BaseSettings base,
             SubtypeResolver strMap<ClassKey,Class<?>> mixins)
     {
         super(basestrmixins);
          = .;
          = null;
     }

    
Copy constructor used to create a non-shared instance with given mix-in annotation definitions and subtype resolver.
 
     {
         super(srcstr);
          = src._deserFeatures;
          = src._nodeFactory;
          = src._problemHandlers;
     }
 
             int mapperFeaturesint deserFeatures)
     {
         super(srcmapperFeatures);
          = deserFeatures;
          = src._nodeFactory;
          = src._problemHandlers;
     }
     
    {
        super(srcbase);
         = src._deserFeatures;
         = src._nodeFactory;
         = src._problemHandlers;
    }
    
    {
        super(src);
         = src._deserFeatures;
         = src._problemHandlers;
         = f;
    }
            LinkedNode<DeserializationProblemHandlerproblemHandlers)
    {
        super(src);
         = src._deserFeatures;
         = problemHandlers;
         = src._nodeFactory;
    }
    private DeserializationConfig(DeserializationConfig srcString rootName)
    {
        super(srcrootName);
         = src._deserFeatures;
         = src._problemHandlers;
         = src._nodeFactory;
    }
    private DeserializationConfig(DeserializationConfig srcClass<?> view)
    {
        super(srcview);
         = src._deserFeatures;
         = src._problemHandlers;
         = src._nodeFactory;
    }

    

Since:
2.1
    protected DeserializationConfig(DeserializationConfig srcMap<ClassKey,Class<?>> mixins)
    {
        super(srcmixins);
         = src._deserFeatures;
         = src._problemHandlers;
         = src._nodeFactory;
    }
    
    // for unit tests only:
    protected BaseSettings getBaseSettings() { return ; }
    
    /*
    /**********************************************************
    /* Life-cycle, factory methods from MapperConfig
    /**********************************************************
     */
    @Override
    public DeserializationConfig with(MapperFeature... features)
    {
        int newMapperFlags = ;
        for (MapperFeature f : features) {
            newMapperFlags |= f.getMask();
        }
        return (newMapperFlags == ) ? this :
            new DeserializationConfig(thisnewMapperFlags);
    }
    @Override
    public DeserializationConfig without(MapperFeature... features)
    {
        int newMapperFlags = ;
        for (MapperFeature f : features) {
             newMapperFlags &= ~f.getMask();
        }
        return (newMapperFlags == ) ? this :
            new DeserializationConfig(thisnewMapperFlags);
    }
    
    @Override
        return _withBase(.withClassIntrospector(ci));
    }
    @Override
        return _withBase(.withAnnotationIntrospector(ai));
    }
    @Override
    public DeserializationConfig with(VisibilityChecker<?> vc) {
        return _withBase(.withVisibilityChecker(vc));
    }
    @Override
        return _withBase.withVisibility(forMethodvisibility));
    }
    
    @Override
        return _withBase(.withTypeResolverBuilder(trb));
    }
    @Override
        return ( == str) ? this : new DeserializationConfig(thisstr);
    }
    
    @Override
        return _withBase(.withPropertyNamingStrategy(pns));
    }
    @Override
    public DeserializationConfig withRootName(String rootName) {
        if (rootName == null) {
            if ( == null) {
                return this;
            }
        } else if (rootName.equals()) {
            return this;
        }
        return new DeserializationConfig(thisrootName);
    }
    
    @Override
    public DeserializationConfig with(TypeFactory tf) {
        return _withBase.withTypeFactory(tf));
    }
    @Override
    public DeserializationConfig with(DateFormat df) {
        return _withBase(.withDateFormat(df));
    }
    
    @Override
        return _withBase(.withHandlerInstantiator(hi));
    }
    @Override
    }
    @Override
    }
    @Override
    public DeserializationConfig withView(Class<?> view) {
        return ( == view) ? this : new DeserializationConfig(thisview);
    }
    @Override
    public DeserializationConfig with(Locale l) {
        return _withBase(.with(l));
    }
    @Override
    public DeserializationConfig with(TimeZone tz) {
        return _withBase(.with(tz));
    }
    @Override
    public DeserializationConfig with(Base64Variant base64) {
        return _withBase(.with(base64));
    }
    
    private final DeserializationConfig _withBase(BaseSettings newBase) {
        return ( == newBase) ? this : new DeserializationConfig(thisnewBase);
    }
    
    /*
    /**********************************************************
    /* Life-cycle, deserialization-specific factory methods
    /**********************************************************
     */

    
Fluent factory method that will construct a new instance with specified com.fasterxml.jackson.databind.node.JsonNodeFactory
        if ( == f) {
            return this;
        }
        return new DeserializationConfig(thisf);
    }

    
Method that can be used to add a handler that can (try to) resolve non-fatal deserialization problems.
    {
        // Sanity check: let's prevent adding same handler multiple times
        if (LinkedNode.contains(h)) {
            return this;
        }
        return new DeserializationConfig(this,
                new LinkedNode<DeserializationProblemHandler>(h));
    }

    
Method for removing all configured problem handlers; usually done to replace existing handler(s) with different one(s)
        if ( == null) {
            return this;
        }
        return new DeserializationConfig(this,
                (LinkedNode<DeserializationProblemHandler>) null);
    }

    
Fluent factory method that will construct and return a new configuration object instance with specified features enabled.
    {
        int newDeserFeatures = ( | feature.getMask());
        return (newDeserFeatures == ) ? this :
            new DeserializationConfig(thisnewDeserFeatures);
    }

    
Fluent factory method that will construct and return a new configuration object instance with specified features enabled.
            DeserializationFeature... features)
    {
        int newDeserFeatures =  | first.getMask();
        for (DeserializationFeature f : features) {
            newDeserFeatures |= f.getMask();
        }
        return (newDeserFeatures == ) ? this :
            new DeserializationConfig(thisnewDeserFeatures);
    }

    
Fluent factory method that will construct and return a new configuration object instance with specified features enabled.
    {
        int newDeserFeatures = ;
        for (DeserializationFeature f : features) {
            newDeserFeatures |= f.getMask();
        }
        return (newDeserFeatures == ) ? this :
            new DeserializationConfig(thisnewDeserFeatures);
    }
    
    
Fluent factory method that will construct and return a new configuration object instance with specified feature disabled.
    {
        int newDeserFeatures =  & ~feature.getMask();
        return (newDeserFeatures == ) ? this :
            new DeserializationConfig(thisnewDeserFeatures);
    }

    
Fluent factory method that will construct and return a new configuration object instance with specified features disabled.
            DeserializationFeature... features)
    {
        int newDeserFeatures =  & ~first.getMask();
        for (DeserializationFeature f : features) {
            newDeserFeatures &= ~f.getMask();
        }
        return (newDeserFeatures == ) ? this :
            new DeserializationConfig(thisnewDeserFeatures);
    }

    
Fluent factory method that will construct and return a new configuration object instance with specified features disabled.
    {
        int newDeserFeatures = ;
        for (DeserializationFeature f : features) {
            newDeserFeatures &= ~f.getMask();
        }
        return (newDeserFeatures == ) ? this :
            new DeserializationConfig(thisnewDeserFeatures);
    }
    
    /*
    /**********************************************************
    /* MapperConfig implementation
    /**********************************************************
     */
    
    
Method for getting AnnotationIntrospector configured to introspect annotation values used for configuration.
    @Override
    {
        /* 29-Jul-2009, tatu: it's now possible to disable use of
         *   annotations; can be done using "no-op" introspector
         */
        if (isEnabled(.)) {
            return super.getAnnotationIntrospector();
        }
        return .;
    }
    @Override
    public boolean useRootWrapping()
    {
        if ( != null) { // empty String disables wrapping; non-empty enables
            return (.length() > 0);
        }
    }
    
    
Accessor for getting bean description that only contains class annotations: useful if no getter/setter/creator information is needed.
    @Override
        return getClassIntrospector().forClassAnnotations(thistypethis);
    }

    
Accessor for getting bean description that only contains immediate class annotations: ones from the class, and its direct mix-in, if any, but not from super types.
    @Override
        return getClassIntrospector().forDirectClassAnnotations(thistypethis);
    }
    @Override
    {
        VisibilityChecker<?> vchecker = super.getDefaultVisibilityChecker();
            vchecker = vchecker.withSetterVisibility(.);
        }
            vchecker = vchecker.withCreatorVisibility(.);
        }
        if (!isEnabled(.)) {
            vchecker = vchecker.withFieldVisibility(.);
        }
        return vchecker;
    }
    public final boolean isEnabled(DeserializationFeature f) {
        return ( & f.getMask()) != 0;
    }
    /*
    /**********************************************************
    /* Other configuration
    /**********************************************************
     */
    public final int getDeserializationFeatures() {
        return ;
    }
    
    
Method for getting head of the problem handler chain. May be null, if no handlers have been added.
        return ;
    }
    public final JsonNodeFactory getNodeFactory() {
        return ;
    }
    
    /*
    /**********************************************************
    /* Introspection methods
    /**********************************************************
     */

    
Method that will introspect full bean properties for the purpose of building a bean deserializer

Parameters:
type Type of class to be introspected
    @SuppressWarnings("unchecked")
    public <T extends BeanDescription> T introspect(JavaType type) {
        return (T) getClassIntrospector().forDeserialization(thistypethis);
    }

    
Method that will introspect subset of bean properties needed to construct bean instance.
    @SuppressWarnings("unchecked")
    public <T extends BeanDescription> T introspectForCreation(JavaType type) {
        return (T) getClassIntrospector().forCreation(thistypethis);
    }

    

Since:
2.0
    @SuppressWarnings("unchecked")
    public <T extends BeanDescription> T introspectForBuilder(JavaType type) {
        return (T) getClassIntrospector().forDeserializationWithBuilder(thistypethis);
    }
New to GrepCode? Check out our FAQ X