package sh.calaba.org.codehaus.jackson.map.deser;
import java.io.IOException;
import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;
import sh.calaba.org.codehaus.jackson.JsonNode;
import sh.calaba.org.codehaus.jackson.JsonParser;
import sh.calaba.org.codehaus.jackson.JsonProcessingException;
import sh.calaba.org.codehaus.jackson.io.SerializedString;
import sh.calaba.org.codehaus.jackson.map.AbstractTypeResolver;
import sh.calaba.org.codehaus.jackson.map.AnnotationIntrospector;
import sh.calaba.org.codehaus.jackson.map.BeanProperty;
import sh.calaba.org.codehaus.jackson.map.ContextualDeserializer;
import sh.calaba.org.codehaus.jackson.map.ContextualKeyDeserializer;
import sh.calaba.org.codehaus.jackson.map.DeserializationConfig;
import sh.calaba.org.codehaus.jackson.map.DeserializationContext;
import sh.calaba.org.codehaus.jackson.map.DeserializerFactory;
import sh.calaba.org.codehaus.jackson.map.DeserializerProvider;
import sh.calaba.org.codehaus.jackson.map.Deserializers;
import sh.calaba.org.codehaus.jackson.map.JsonDeserializer;
import sh.calaba.org.codehaus.jackson.map.JsonMappingException;
import sh.calaba.org.codehaus.jackson.map.KeyDeserializer;
import sh.calaba.org.codehaus.jackson.map.KeyDeserializers;
import sh.calaba.org.codehaus.jackson.map.ResolvableDeserializer;
import sh.calaba.org.codehaus.jackson.map.TypeDeserializer;
import sh.calaba.org.codehaus.jackson.map.introspect.AnnotatedClass;
import sh.calaba.org.codehaus.jackson.map.type.ArrayType;
import sh.calaba.org.codehaus.jackson.map.type.CollectionLikeType;
import sh.calaba.org.codehaus.jackson.map.type.CollectionType;
import sh.calaba.org.codehaus.jackson.map.type.MapLikeType;
import sh.calaba.org.codehaus.jackson.map.type.MapType;
import sh.calaba.org.codehaus.jackson.map.util.ClassUtil;
import sh.calaba.org.codehaus.jackson.map.util.RootNameLookup;
import sh.calaba.org.codehaus.jackson.type.JavaType;
/**
* Default {@link DeserializerProvider} implementation.
* Handles low-level caching (non-root) aspects of deserializer
* handling; all construction details are delegated to configured
* {@link DeserializerFactory} instance that the provider owns.
*/
public class StdDeserializerProvider
extends DeserializerProvider
{
/*
/**********************************************************
/* Caching
/**********************************************************
*/
/**
* We will also cache some dynamically constructed deserializers;
* specifically, ones that are expensive to construct.
* This currently means bean and Enum deserializers; array, List and Map
* deserializers will not be cached.
*
* Given that we don't expect much concurrency for additions
* (should very quickly converge to zero after startup), let's
* explicitly define a low concurrency setting.
*/
final protected ConcurrentHashMap> _cachedDeserializers
= new ConcurrentHashMap>(64, 0.75f, 2);
/**
* During deserializer construction process we may need to keep track of partially
* completed deserializers, to resolve cyclic dependencies. This is the
* map used for storing deserializers before they are fully complete.
*/
final protected HashMap> _incompleteDeserializers
= new HashMap>(8);
final protected RootNameLookup _rootNames;
/*
/**********************************************************
/* Configuration
/**********************************************************
*/
/**
* Factory responsible for constructing actual deserializers, if not
* one of pre-configured types.
*/
protected DeserializerFactory _factory;
/*
/**********************************************************
/* Life-cycle
/**********************************************************
*/
/**
* Default constructor. Equivalent to calling
*
* new StdDeserializerProvider(BeanDeserializerFactory.instance);
*
*/
public StdDeserializerProvider() { this(BeanDeserializerFactory.instance); }
public StdDeserializerProvider(DeserializerFactory f) {
_factory = f;
_rootNames = new RootNameLookup();
}
@Override
public DeserializerProvider withAdditionalDeserializers(Deserializers d) {
return withFactory(_factory.withAdditionalDeserializers(d));
}
@Override
public DeserializerProvider withAdditionalKeyDeserializers(KeyDeserializers d) {
return withFactory(_factory.withAdditionalKeyDeserializers(d));
}
@Override
public DeserializerProvider withDeserializerModifier(BeanDeserializerModifier modifier) {
return withFactory(_factory.withDeserializerModifier(modifier));
}
@Override
public DeserializerProvider withAbstractTypeResolver(AbstractTypeResolver resolver) {
return withFactory(_factory.withAbstractTypeResolver(resolver));
}
@Override
public DeserializerProvider withValueInstantiators(ValueInstantiators instantiators) {
return withFactory(_factory.withValueInstantiators(instantiators));
}
@Override
public StdDeserializerProvider withFactory(DeserializerFactory factory) {
// sanity-check to try to prevent hard-to-debug problems; sub-classes MUST override this method
if (this.getClass() != StdDeserializerProvider.class) {
throw new IllegalStateException("DeserializerProvider of type "
+this.getClass().getName()+" does not override 'withFactory()' method");
}
return new StdDeserializerProvider(factory);
}
/*
/**********************************************************
/* Abstract methods impls
/**********************************************************
*/
@Override
public JavaType mapAbstractType(DeserializationConfig config, JavaType type)
throws JsonMappingException
{
return _factory.mapAbstractType(config, type);
}
@Override
public SerializedString findExpectedRootName(DeserializationConfig config, JavaType type)
throws JsonMappingException
{
return _rootNames.findRootName(type, config);
}
@SuppressWarnings("unchecked")
@Override
public JsonDeserializer