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 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;
import com.fasterxml.jackson.databind.util.LRUMap;
/**
* 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
{
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, Enum and container deserializers.
*/
final protected LRUMap> _cachedDeserializers;
/**
* 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() {
this(2000); // see [databind#1995]
}
public DeserializerCache(int maxSize) {
int initial = Math.min(64, maxSize>>2);
_cachedDeserializers = new LRUMap<>(initial, maxSize);
}
/*
/**********************************************************
/* JDK serialization handling
/**********************************************************
*/
Object writeReplace() {
// instead of making this transient, just clear it:
_incompleteDeserializers.clear();
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