Top Description Inners Fields Constructors Methods
com.fasterxml.jackson.databind.cfg

public Class DefaultCacheProvider

extends Object
implements CacheProvider
Class Inheritance
All Implemented Interfaces
com.fasterxml.jackson.databind.cfg.CacheProvider, java.io.Serializable
Imports
com.fasterxml.jackson.databind.*, com.fasterxml.jackson.databind.deser.DeserializerCache, com.fasterxml.jackson.databind.ser.SerializerCache, com.fasterxml.jackson.databind.type.TypeFactory, com.fasterxml.jackson.databind.util.LRUMap, .LookupCache, .TypeKey

The default implementation of CacheProvider. Configuration is builder-based via DefaultCacheProvider.Builder.

Users can either use this class or create their own CacheProvider implementation.

Since
2.16

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
DefaultCacheProvider.Builder

Builder offering fluent factory methods to configure DefaultCacheProvider, keeping it immutable.

Field Summary

Modifier and TypeField and Description
protected final int
protected final int
protected final int
_maxTypeFactoryCacheSize

Maximum size of the LookupCache instance constructed by forTypeFactory().

private static final DefaultCacheProvider
private static final long

Constructor Summary

AccessConstructor and Description
protected
DefaultCacheProvider(int maxDeserializerCacheSize, int maxSerializerCacheSize, int maxTypeFactoryCacheSize)

Method Summary

Modifier and TypeMethod and Description
protected <K, V> LookupCache<K, V>
_buildCache(int maxSize)

public static DefaultCacheProvider.Builder

Returns:

Builder instance for configuration.
builder
()

public static CacheProvider

Returns:

Default DefaultCacheProvider instance using default configuration values.
defaultInstance
()

public LookupCache<JavaType, JsonDeserializer<Object>>
public LookupCache<TypeKey, JsonSerializer<Object>>
public LookupCache<Object, JavaType>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_maxDeserializerCacheSizeback to summary
protected final int _maxDeserializerCacheSize

Maximum size of the LookupCache instance constructed by forDeserializerCache(DeserializationConfig).

See Also
Builder#maxDeserializerCacheSize(int)
_maxSerializerCacheSizeback to summary
protected final int _maxSerializerCacheSize

Maximum size of the LookupCache instance constructed by forSerializerCache(SerializationConfig)

See Also
Builder#maxSerializerCacheSize(int)
_maxTypeFactoryCacheSizeback to summary
protected final int _maxTypeFactoryCacheSize

Maximum size of the LookupCache instance constructed by forTypeFactory().

See Also
Builder#maxTypeFactoryCacheSize(int)
DEFAULTback to summary
private static final DefaultCacheProvider DEFAULT
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

DefaultCacheProviderback to summary
protected DefaultCacheProvider(int maxDeserializerCacheSize, int maxSerializerCacheSize, int maxTypeFactoryCacheSize)

Method Detail

_buildCacheback to summary
protected <K, V> LookupCache<K, V> _buildCache(int maxSize)
builderback to summary
public static DefaultCacheProvider.Builder builder()
Returns:DefaultCacheProvider.Builder

Builder instance for configuration.

defaultInstanceback to summary
public static CacheProvider defaultInstance()
Returns:CacheProvider

Default DefaultCacheProvider instance using default configuration values.

forDeserializerCacheback to summary
public LookupCache<JavaType, JsonDeserializer<Object>> forDeserializerCache(DeserializationConfig config)

Implements com.fasterxml.jackson.databind.cfg.CacheProvider.forDeserializerCache.

Method to provide a LookupCache instance for constructing DeserializerCache. Implementation should match DeserializerCache#DeserializerCache(int).

Returns:LookupCache<JavaType, JsonDeserializer<Object>>

LookupCache instance for constructing DeserializerCache.

Annotations
@Override
forSerializerCacheback to summary
public LookupCache<TypeKey, JsonSerializer<Object>> forSerializerCache(SerializationConfig config)

Implements com.fasterxml.jackson.databind.cfg.CacheProvider.forSerializerCache.

Doc from com.fasterxml.jackson.databind.cfg.CacheProvider.forSerializerCache.

Method for constructing a LookupCache instance to be used by com.fasterxml.jackson.databind.ser.SerializerCache.

Returns:LookupCache<TypeKey, JsonSerializer<Object>>

LookupCache instance for constructing com.fasterxml.jackson.databind.ser.SerializerCache.

Annotations
@Override
forTypeFactoryback to summary
public LookupCache<Object, JavaType> forTypeFactory()

Implements com.fasterxml.jackson.databind.cfg.CacheProvider.forTypeFactory.

Doc from com.fasterxml.jackson.databind.cfg.CacheProvider.forTypeFactory.

Method for constructing a LookupCache instance to be used by com.fasterxml.jackson.databind.type.TypeFactory.

Returns:LookupCache<Object, JavaType>

LookupCache instance for constructing com.fasterxml.jackson.databind.type.TypeFactory.

Annotations
@Override
com.fasterxml.jackson.databind.cfg back to summary

public Class DefaultCacheProvider.Builder

extends Object
Class Inheritance
  • java.lang.Object
  • com.fasterxml.jackson.databind.cfg.DefaultCacheProvider.Builder

Builder offering fluent factory methods to configure DefaultCacheProvider, keeping it immutable.

Field Summary

Modifier and TypeField and Description
private int
private int
private int
_maxTypeFactoryCacheSize

Maximum Size of the LookupCache instance created by forTypeFactory().

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public DefaultCacheProvider

Returns:

A DefaultCacheProvider instance with the specified configuration
build
()

Constructs a DefaultCacheProvider with the provided configuration values, using defaults where not specified.

public DefaultCacheProvider.Builder

Returns:

this builder
maxDeserializerCacheSize
(int
Size for the LookupCache to use within DeserializerCache
maxDeserializerCacheSize
)

Define the maximum size of the LookupCache instance constructed by forDeserializerCache(DeserializationConfig) and _buildCache(int).

public DefaultCacheProvider.Builder

Returns:

this builder
maxSerializerCacheSize
(int
Size for the LookupCache to use within SerializerCache
maxSerializerCacheSize
)

Define the maximum size of the LookupCache instance constructed by forSerializerCache(SerializationConfig) and _buildCache(int)

Note that specifying a maximum size of zero prevents values from being retained in the cache.

public DefaultCacheProvider.Builder

Returns:

this builder
maxTypeFactoryCacheSize
(int maxTypeFactoryCacheSize)

Define the maximum size of the LookupCache instance constructed by forTypeFactory() and _buildCache(int)

Note that specifying a maximum size of zero prevents values from being retained in the cache.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_maxDeserializerCacheSizeback to summary
private int _maxDeserializerCacheSize

Maximum Size of the LookupCache instance created by forDeserializerCache(DeserializationConfig). Corresponds to DefaultCacheProvider#_maxDeserializerCacheSize.

_maxSerializerCacheSizeback to summary
private int _maxSerializerCacheSize

Maximum Size of the LookupCache instance created by forSerializerCache(SerializationConfig) Corresponds to DefaultCacheProvider#_maxSerializerCacheSize.

_maxTypeFactoryCacheSizeback to summary
private int _maxTypeFactoryCacheSize

Maximum Size of the LookupCache instance created by forTypeFactory(). Corresponds to DefaultCacheProvider#_maxTypeFactoryCacheSize.

Constructor Detail

Builderback to summary
pack-priv Builder()

Method Detail

buildback to summary
public DefaultCacheProvider build()

Constructs a DefaultCacheProvider with the provided configuration values, using defaults where not specified.

Returns:DefaultCacheProvider

A DefaultCacheProvider instance with the specified configuration

maxDeserializerCacheSizeback to summary
public DefaultCacheProvider.Builder maxDeserializerCacheSize(int maxDeserializerCacheSize)

Define the maximum size of the LookupCache instance constructed by forDeserializerCache(DeserializationConfig) and _buildCache(int).

Note that specifying a maximum size of zero prevents values from being retained in the cache.

Parameters
maxDeserializerCacheSize:int

Size for the LookupCache to use within DeserializerCache

Returns:DefaultCacheProvider.Builder

this builder

Exceptions
IllegalArgumentException:
if maxDeserializerCacheSize is negative
Since
2.16
maxSerializerCacheSizeback to summary
public DefaultCacheProvider.Builder maxSerializerCacheSize(int maxSerializerCacheSize)

Define the maximum size of the LookupCache instance constructed by forSerializerCache(SerializationConfig) and _buildCache(int)

Note that specifying a maximum size of zero prevents values from being retained in the cache.

Parameters
maxSerializerCacheSize:int

Size for the LookupCache to use within SerializerCache

Returns:DefaultCacheProvider.Builder

this builder

Exceptions
IllegalArgumentException:
if maxSerializerCacheSize is negative
Since
2.16
maxTypeFactoryCacheSizeback to summary
public DefaultCacheProvider.Builder maxTypeFactoryCacheSize(int maxTypeFactoryCacheSize)

Define the maximum size of the LookupCache instance constructed by forTypeFactory() and _buildCache(int)

Note that specifying a maximum size of zero prevents values from being retained in the cache.

Parameters
maxTypeFactoryCacheSize:int

Size for the LookupCache to use within com.fasterxml.jackson.databind.type.TypeFactory

Returns:DefaultCacheProvider.Builder

this builder

Exceptions
IllegalArgumentException:
if maxTypeFactoryCacheSize is negative