Top Description Fields Constructors Methods
com.fasterxml.jackson.databind.util

public Class LRUMap<K, V>

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

Helper for simple bounded maps used for reusing lookup values.

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 cache size of Map.

Since Jackson 2.12, there has been pluggable LookupCache interface which allows users, frameworks, provide their own cache implementations.

Since Jackson 2.14, the implementation

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
LRUMap(int initialEntries, int maxEntries)

Method Summary

Modifier and TypeMethod and Description
public void
clear()

Implements com.fasterxml.jackson.databind.util.LookupCache.clear.

Method for removing all contents this cache has.

public void
contents(BiConsumer<K, V>
Operation to apply on cache contents.
consumer
)

Overrides default com.fasterxml.jackson.databind.util.LookupCache.contents.

Method to apply operation on cache contents without exposing them.

public LookupCache<K, V>
emptyCopy()

Overrides default com.fasterxml.jackson.databind.util.LookupCache.emptyCopy.

Method needed for creating clones but without contents.

public V
get(Object key)

Implements com.fasterxml.jackson.databind.util.LookupCache.get.

Note

key is of type Object only to retain binary backwards-compatibility

public V
public V
protected Object
public int
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

LRUMapback to summary
public LRUMap(int initialEntries, int maxEntries)

Method Detail

clearback to summary
public void clear()

Implements com.fasterxml.jackson.databind.util.LookupCache.clear.

Doc from com.fasterxml.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 com.fasterxml.jackson.databind.util.LookupCache.contents.

Doc from com.fasterxml.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.

Parameters
consumer:BiConsumer<K, V>

Operation to apply on cache contents.

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

Overrides default com.fasterxml.jackson.databind.util.LookupCache.emptyCopy.

Doc from com.fasterxml.jackson.databind.util.LookupCache.emptyCopy.

Method needed for creating clones but without contents.

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

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

Implements com.fasterxml.jackson.databind.util.LookupCache.get.

Doc from com.fasterxml.jackson.databind.util.LookupCache.get.

Note

key is of type Object only to retain binary backwards-compatibility

Returns:V

value associated with key (can return null)

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

Implements com.fasterxml.jackson.databind.util.LookupCache.put.

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

Implements com.fasterxml.jackson.databind.util.LookupCache.putIfAbsent.

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

Implements com.fasterxml.jackson.databind.util.LookupCache.size.

Returns:int

Doc from com.fasterxml.jackson.databind.util.LookupCache.size.

Number of entries currently in cache: may be approximate, only to be used for diagnostics, metrics reporting

Annotations
@Override