@Experimental public final class FunctionalNotifierImpl<K,V> extends Object implements FunctionalNotifier<K,V>
Listeners.ReadWriteListeners.ReadWriteListener<K,V>
Listeners.WriteListeners.WriteListener<K,V>
Constructor and Description |
---|
FunctionalNotifierImpl() |
Modifier and Type | Method and Description |
---|---|
AutoCloseable |
add(Listeners.ReadWriteListeners.ReadWriteListener<K,V> l)
Add a read-write listener, and return an
AutoCloseable
instance that can be used to remove the listener registration. |
AutoCloseable |
add(Listeners.WriteListeners.WriteListener<K,V> l)
Add a write-only listener, and return an
AutoCloseable
instance that can be used to remove the listener registration. |
void |
notifyOnCreate(CacheEntry entry)
Notify registered
ReadWriteListener instances of the created entry. |
void |
notifyOnModify(CacheEntry<K,V> entry,
V previousValue,
Metadata previousMetadata)
Notify registered
ReadWriteListener instances of the modified
entry passing the previous and new value. |
void |
notifyOnRemove(EntryView.ReadEntryView<K,V> removed)
Notify registered
ReadWriteListener instances of the removed
entry passing in the removed entry. |
void |
notifyOnWrite(CacheEntry<K,V> entry) |
void |
notifyOnWriteRemove(K key)
Notify registered
WriteListener instances of the written entry. |
AutoCloseable |
onCreate(Consumer<EntryView.ReadEntryView<K,V>> f)
Add a create event specific listener by passing in a
Consumer to be called back each time a new cache entry is
created, passing in a EntryView.ReadEntryView of that new entry. |
AutoCloseable |
onModify(BiConsumer<EntryView.ReadEntryView<K,V>,EntryView.ReadEntryView<K,V>> f)
Add a modify/update event specific listener by passing in a
BiConsumer to be called back each time an entry is
modified or updated, passing in a EntryView.ReadEntryView of the
previous entry as first parameter, and a EntryView.ReadEntryView of the
new value as second parameter. |
AutoCloseable |
onRemove(Consumer<EntryView.ReadEntryView<K,V>> f)
Add a remove event specific listener by passing in a
Consumer to be called back each time an entry is
removed, passing in the EntryView.ReadEntryView of the removed entry. |
AutoCloseable |
onWrite(Consumer<EntryView.ReadEntryView<K,V>> f)
Add a write event listener by passing in a
Consumer to be
called each time a cache entry is created, modified/updated or
removed. |
public AutoCloseable add(Listeners.WriteListeners.WriteListener<K,V> l)
Listeners.WriteListeners
AutoCloseable
instance that can be used to remove the listener registration.add
in interface Listeners.WriteListeners<K,V>
l
- the write-only functional map event listenerAutoCloseable
instance that can be used to
unregister the listenerpublic AutoCloseable add(Listeners.ReadWriteListeners.ReadWriteListener<K,V> l)
Listeners.ReadWriteListeners
AutoCloseable
instance that can be used to remove the listener registration.add
in interface Listeners.ReadWriteListeners<K,V>
l
- the read-write functional map event listenerAutoCloseable
instance that can be used to
unregister the listenerpublic AutoCloseable onCreate(Consumer<EntryView.ReadEntryView<K,V>> f)
Listeners.ReadWriteListeners
Consumer
to be called back each time a new cache entry is
created, passing in a EntryView.ReadEntryView
of that new entry.
This method is shortcut for users who are only interested in
create events. If interested in multiple event types, calling
Listeners.ReadWriteListeners.add(ReadWriteListener)
is recommended instead.
onCreate
in interface Listeners.ReadWriteListeners<K,V>
f
- operation to be called each time a new cache entry is createdAutoCloseable
instance that can be used to
unregister the listenerpublic AutoCloseable onModify(BiConsumer<EntryView.ReadEntryView<K,V>,EntryView.ReadEntryView<K,V>> f)
Listeners.ReadWriteListeners
BiConsumer
to be called back each time an entry is
modified or updated, passing in a EntryView.ReadEntryView
of the
previous entry as first parameter, and a EntryView.ReadEntryView
of the
new value as second parameter.
This method is shortcut for users who are only interested in
update events. If interested in multiple event types, calling
Listeners.ReadWriteListeners.add(ReadWriteListener)
is recommended instead.
onModify
in interface Listeners.ReadWriteListeners<K,V>
f
- operation to be called each time a new cache entry is modified or updated,
with the first parameter the EntryView.ReadEntryView
of the previous
entry value, and the second parameter the new EntryView.ReadEntryView
AutoCloseable
instance that can be used to
unregister the listenerpublic AutoCloseable onRemove(Consumer<EntryView.ReadEntryView<K,V>> f)
Listeners.ReadWriteListeners
Consumer
to be called back each time an entry is
removed, passing in the EntryView.ReadEntryView
of the removed entry.
This method is shortcut for users who are only interested in
remove events. If interested in multiple event types, calling
Listeners.ReadWriteListeners.add(ReadWriteListener)
is recommended instead.
onRemove
in interface Listeners.ReadWriteListeners<K,V>
f
- operation to be called each time a new cache entry is removed,
with the old cached entry's EntryView.ReadEntryView
as parameter.AutoCloseable
instance that can be used to
unregister the listenerpublic AutoCloseable onWrite(Consumer<EntryView.ReadEntryView<K,V>> f)
Listeners.WriteListeners
Consumer
to be
called each time a cache entry is created, modified/updated or
removed.
For created or modified/updated events, the
EntryView.ReadEntryView
passed in will represent the newly stored
entry, hence implementations will not be available to differentiate
between created events vs modified/updated events.
For removed events, EntryView.ReadEntryView
passed in will represent
an empty entry view, hence EntryView.ReadEntryView.find()
will return
an empty Optional
instance, and
EntryView.ReadEntryView.get()
will throw
NoSuchElementException
.
onWrite
in interface Listeners.WriteListeners<K,V>
f
- operation to be called each time a cache entry is writtenAutoCloseable
instance that can be used to
unregister the listenerpublic void notifyOnCreate(CacheEntry entry)
FunctionalNotifier
ReadWriteListener
instances of the created entry.notifyOnCreate
in interface FunctionalNotifier<K,V>
public void notifyOnModify(CacheEntry<K,V> entry, V previousValue, Metadata previousMetadata)
FunctionalNotifier
ReadWriteListener
instances of the modified
entry passing the previous and new value.notifyOnModify
in interface FunctionalNotifier<K,V>
public void notifyOnRemove(EntryView.ReadEntryView<K,V> removed)
FunctionalNotifier
ReadWriteListener
instances of the removed
entry passing in the removed entry.notifyOnRemove
in interface FunctionalNotifier<K,V>
public void notifyOnWrite(CacheEntry<K,V> entry)
notifyOnWrite
in interface FunctionalNotifier<K,V>
public void notifyOnWriteRemove(K key)
FunctionalNotifier
WriteListener
instances of the written entry.notifyOnWriteRemove
in interface FunctionalNotifier<K,V>
Copyright © 2021 JBoss by Red Hat. All rights reserved.