Class DeserializerCache
- java.lang.Object
-
- com.fasterxml.jackson.databind.deser.DeserializerCache
-
- All Implemented Interfaces:
java.io.Serializable
public final class DeserializerCache extends java.lang.Object implements java.io.Serializable
Class that defines caching layer between callers (likeObjectMapper
,DeserializationContext
) and classes that construct deserializers (DeserializerFactory
).- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DeserializerCache()
DeserializerCache(int maxSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
cachedDeserializersCount()
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).KeyDeserializer
findKeyDeserializer(DeserializationContext ctxt, DeserializerFactory factory, JavaType type)
Method called to get hold of a deserializer to use for deserializing keys forMap
.JsonDeserializer<java.lang.Object>
findValueDeserializer(DeserializationContext ctxt, DeserializerFactory factory, JavaType propertyType)
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).void
flushCachedDeserializers()
Method that will drop all dynamically constructed deserializers (ones that are counted as result value forcachedDeserializersCount()
).boolean
hasValueDeserializerFor(DeserializationContext ctxt, DeserializerFactory factory, JavaType type)
Method called to find out whether provider would be able to find a deserializer for given type, using a root reference (i.e.
-
-
-
Method Detail
-
cachedDeserializersCount
public int cachedDeserializersCount()
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.
-
flushCachedDeserializers
public void flushCachedDeserializers()
Method that will drop all dynamically constructed deserializers (ones that are counted as result value forcachedDeserializersCount()
). 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.
-
findValueDeserializer
public JsonDeserializer<java.lang.Object> findValueDeserializer(DeserializationContext ctxt, DeserializerFactory factory, JavaType propertyType) throws JsonMappingException
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
findKeyDeserializer(com.fasterxml.jackson.databind.DeserializationContext, com.fasterxml.jackson.databind.deser.DeserializerFactory, com.fasterxml.jackson.databind.JavaType)
.Note also that deserializer returned is guaranteed to be resolved (if it is of type
ResolvableDeserializer
), but not contextualized (wrtContextualDeserializer
): caller has to handle latter if necessary.- Parameters:
ctxt
- Deserialization contextpropertyType
- 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
-
findKeyDeserializer
public KeyDeserializer findKeyDeserializer(DeserializationContext ctxt, DeserializerFactory factory, JavaType type) throws JsonMappingException
Method called to get hold of a deserializer to use for deserializing keys forMap
.- Throws:
JsonMappingException
- if there are fatal problems with accessing suitable key deserializer; including that of not finding any serializer
-
hasValueDeserializerFor
public boolean hasValueDeserializerFor(DeserializationContext ctxt, DeserializerFactory factory, JavaType type) throws JsonMappingException
Method called to find out whether provider would be able to find a deserializer for given type, using a root reference (i.e. not through fields or membership in an array or collection)- Throws:
JsonMappingException
-
-