Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package com.fasterxml.jackson.databind.deser;
import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.deser.std.StdDelegatingDeserializer;
import com.fasterxml.jackson.databind.introspect.Annotated;
import com.fasterxml.jackson.databind.type.*;
import com.fasterxml.jackson.databind.util.ClassUtil;
import com.fasterxml.jackson.databind.util.Converter;
/**
* Class that defines caching layer between callers (like
* {@link ObjectMapper},
* {@link com.fasterxml.jackson.databind.DeserializationContext})
* and classes that construct deserializers
* ({@link com.fasterxml.jackson.databind.deser.DeserializerFactory}).
*/
public final class DeserializerCache
implements java.io.Serializable // since 2.1 -- needs to be careful tho
{
private static final long serialVersionUID = 1L;
/*
/**********************************************************
/* 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);
/*
/**********************************************************
/* Life-cycle
/**********************************************************
*/
public DeserializerCache() { }
/*
/**********************************************************
/* JDK serialization handling
/**********************************************************
*/
Object writeReplace() {
// instead of making this transient, just clear it:
_incompleteDeserializers.clear();
// TODO: clear out "cheap" cached deserializers?
return this;
}
/*
/**********************************************************
/* Access to caching aspects
/**********************************************************
*/
/**
* Method that can be used to determine how many deserializers this
* provider is caching currently
* (if it does caching: default implementation does)
* Exact count depends on what kind of deserializers get cached;
* default implementation caches only dynamically constructed deserializers,
* but not eagerly constructed standard deserializers (which is different
* from how serializer provider works).
*
* The main use case for this method is to allow conditional flushing of
* deserializer cache, if certain number of entries is reached.
*/
public int cachedDeserializersCount() {
return _cachedDeserializers.size();
}
/**
* Method that will drop all dynamically constructed deserializers (ones that
* are counted as result value for {@link #cachedDeserializersCount}).
* This can be used to remove memory usage (in case some deserializers are
* only used once or so), or to force re-construction of deserializers after
* configuration changes for mapper than owns the provider.
*/
public void flushCachedDeserializers() {
_cachedDeserializers.clear();
}
/*
/**********************************************************
/* General deserializer locating method
/**********************************************************
*/
/**
* Method called to get hold of a deserializer for a value of given type;
* or if no such deserializer can be found, a default handler (which
* may do a best-effort generic serialization or just simply
* throw an exception when invoked).
*
* Note: this method is only called for value types; not for keys.
* Key deserializers can be accessed using {@link #findKeyDeserializer}.
*
* Note also that deserializer returned is guaranteed to be resolved
* (if it is of type {@link ResolvableDeserializer}), but
* not contextualized (wrt {@link ContextualDeserializer}): caller
* has to handle latter if necessary.
*
* @param ctxt Deserialization context
* @param propertyType Declared type of the value to deserializer (obtained using
* 'setter' method signature and/or type annotations
*
* @throws JsonMappingException if there are fatal problems with
* accessing suitable deserializer; including that of not
* finding any serializer
*/
public JsonDeserializer