Top Description Fields Constructors Methods
tools.jackson.databind.util

public Class SimpleLookupCache<K, V>

extends Object
implements LookupCache<K, V>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, tools.jackson.databind.util.LookupCache, tools.jackson.core.util.Snapshottable
Imports
java.util.Map, java.util.function.BiConsumer, tools.jackson.databind.util.internal.PrivateMaxEntriesMap

Synchronized cache with bounded size: used for reusing lookup values and lazily instantiated reusable items.

Note that serialization behavior is such that contents are NOT serialized, on assumption that all use cases are for caching where persistence does not make sense. The only thing serialized is the initial and maximum size of the contents.

The implementation evicts the least recently used entry when max size is reached; this is implemented by the backing PrivateMaxEntriesMap implementation. Implementation is thread-safe and does NOT require external synchronization

Note

in Jackson 2.x this class was named com.fasterxml.jackson.databind.util.LRUMap

Field Summary

Modifier and TypeField and Description
protected final int
protected final transient PrivateMaxEntriesMap<K, V>
protected final int
private static final long

Constructor Summary

AccessConstructor and Description
public
SimpleLookupCache(int initialEntries, int maxEntries)

Method Summary

Modifier and TypeMethod and Description
public void
clear()

Implements tools.jackson.databind.util.LookupCache.clear.

Method for removing all contents this cache has.

public void
contents(BiConsumer<K, V> consumer)

Overrides default tools.jackson.databind.util.LookupCache.contents.

Method to apply operation on cache contents without exposing them.

public LookupCache<K, V>
emptyCopy()

Implements tools.jackson.databind.util.LookupCache.emptyCopy.

Method needed for creating clones but without contents.

public V
public V
public V
protected Object
public int
public SimpleLookupCache<K, V>
snapshot()

Implements tools.jackson.core.util.Snapshottable.snapshot.

Method to call to get an instance that may not be modified through any other object, including `this`.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_initialEntriesback to summary
protected final int _initialEntries
_mapback to summary
protected final transient PrivateMaxEntriesMap<K, V> _map
_maxEntriesback to summary
protected final int _maxEntries
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

SimpleLookupCacheback to summary
public SimpleLookupCache(int initialEntries, int maxEntries)

Method Detail

clearback to summary
public void clear()

Implements tools.jackson.databind.util.LookupCache.clear.

Doc from tools.jackson.databind.util.LookupCache.clear.

Method for removing all contents this cache has.

Annotations
@Override
contentsback to summary
public void contents(BiConsumer<K, V> consumer)

Overrides default tools.jackson.databind.util.LookupCache.contents.

Doc from tools.jackson.databind.util.LookupCache.contents.

Method to apply operation on cache contents without exposing them.

Default implementation throws UnsupportedOperationException. Implementations are required to override this method.

Annotations
@Override
emptyCopyback to summary
public LookupCache<K, V> emptyCopy()

Implements tools.jackson.databind.util.LookupCache.emptyCopy.

Doc from tools.jackson.databind.util.LookupCache.emptyCopy.

Method needed for creating clones but without contents.

Annotations
@Override
getback to summary
public V get(K key)

Implements tools.jackson.databind.util.LookupCache.get.

Annotations
@Override
putback to summary
public V put(K key, V value)

Implements tools.jackson.databind.util.LookupCache.put.

Annotations
@Override
putIfAbsentback to summary
public V putIfAbsent(K key, V value)

Implements tools.jackson.databind.util.LookupCache.putIfAbsent.

Annotations
@Override
readResolveback to summary
protected Object readResolve()
sizeback to summary
public int size()

Implements tools.jackson.databind.util.LookupCache.size.

Annotations
@Override
snapshotback to summary
public SimpleLookupCache<K, V> snapshot()

Implements tools.jackson.core.util.Snapshottable.snapshot.

Doc from tools.jackson.core.util.Snapshottable.snapshot.

Method to call to get an instance that may not be modified through any other object, including `this`. That instance may be `this` if (and only if) this instance is effectively immutable (unmodifiable) through its API: if this is not the case, a new copy with same configuration must be created and returned.

Annotations
@Override