K
- key type of the maps, trackable by this event listenerV
- value type of the maps, trackable by this event listenerM
- ChronicleMap
subtype, trackable by this event listenerpublic abstract class MapEventListener<K,V,M extends ChronicleMap<K,V>> extends Object implements Serializable
ChronicleMap
key events occur. Typical use cases: This is an adapter class - all methods have default implementations as no-ops. Extend this class and override only methods corresponding the events you are interested in.
To configure MapEventListener
for ChronicleMap
, use AbstractChronicleMapBuilder.eventListener(MapEventListener)
method.
MapEventListeners
uninstantiable class contains several logging implementations and the default
no-op implementation.
All these calls are synchronous while a ChronicleMap
lock is held so make them as quick as
possible.
The entry
passed to the methods is Bytes
instance positioned at meta data area. See
ChronicleHashBuilder.metaDataBytes(int)
for more information.
Constructor and Description |
---|
MapEventListener() |
Modifier and Type | Method and Description |
---|---|
void |
onGetFound(M map,
Bytes entry,
int metaDataBytes,
K key,
V value)
This method is called if the key is found in the map during
get , getUsing or acquireUsing method call. |
void |
onPut(M map,
Bytes entry,
int metaDataBytes,
boolean added,
K key,
V value,
V replacedValue)
This method is called whenever a new value is put for the key in the map during calls of such methods
as
put , putIfAbsent , replace , etc. |
void |
onRemove(M map,
Bytes entry,
int metaDataBytes,
K key,
V value)
This is called when an entry is removed.
|
public void onGetFound(M map, Bytes entry, int metaDataBytes, K key, V value)
get
, getUsing
or acquireUsing
method call.map
- the accessed mapentry
- bytes of the entrymetaDataBytes
- length of meta data
for this mapkey
- the key looked upvalue
- the value found for the keypublic void onPut(M map, Bytes entry, int metaDataBytes, boolean added, K key, V value, @Nullable V replacedValue)
put
, putIfAbsent
, replace
, etc. When a new value is default for the map or obtained during acquireUsing
call is put for the key, this method is called as well.
This method is called when put is already happened.
map
- the accessed mapentry
- bytes of the entry (with the value already written to)metaDataBytes
- length of meta data
for this mapadded
- true
is the key was absent in the map before current ChronicleMap
method call, led to putting a value and inherently calling this listener methodkey
- the key the given value is put forvalue
- the value which is now associated with the given keyreplacedValue
- the value which was replaced by value
, is NULL if added
is truepublic void onRemove(M map, Bytes entry, int metaDataBytes, K key, V value)
map.remove(key)
is called, but key
is already absent in the map, are not notified.map
- accessedentry
- bytes of the entry just removed, but any data is not yet erasedmetaDataBytes
- length of meta data
for this mapkey
- the key removed from the mapvalue
- the value which was associated with the given keyCopyright © 2014. All rights reserved.