Class MappingListenerManager<K,V>
- java.lang.Object
-
- org.apache.curator.framework.listen.MappingListenerManager<K,V>
-
- All Implemented Interfaces:
Listenable<K>
,ListenerManager<K,V>
public class MappingListenerManager<K,V> extends Object implements ListenerManager<K,V>
Version of ListenerManager that supports mapping/wrapping of listeners
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(K listener)
Add the given listener.void
addListener(K listener, Executor executor)
Add the given listener.void
clear()
Remove all listenersvoid
forEach(Consumer<V> function)
Utility - apply the given function to each listener.static <K,V>
ListenerManager<K,V>mapping(Function<K,V> mapper)
Returns a new container that wraps listeners using the given mappervoid
removeListener(K listener)
Remove the given listenerint
size()
Return the number of listeners-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.curator.framework.listen.ListenerManager
isEmpty
-
-
-
-
Method Detail
-
mapping
public static <K,V> ListenerManager<K,V> mapping(Function<K,V> mapper)
Returns a new container that wraps listeners using the given mapper- Parameters:
mapper
- listener mapper/wrapper- Returns:
- new container
-
addListener
public void addListener(K listener)
Description copied from interface:Listenable
Add the given listener. The listener will be executed in the containing instance's thread.- Specified by:
addListener
in interfaceListenable<K>
- Parameters:
listener
- listener to add
-
addListener
public void addListener(K listener, Executor executor)
Description copied from interface:Listenable
Add the given listener. The listener will be executed using the given executor- Specified by:
addListener
in interfaceListenable<K>
- Parameters:
listener
- listener to addexecutor
- executor to run listener in
-
removeListener
public void removeListener(K listener)
Description copied from interface:Listenable
Remove the given listener- Specified by:
removeListener
in interfaceListenable<K>
- Parameters:
listener
- listener to remove
-
clear
public void clear()
Description copied from interface:ListenerManager
Remove all listeners- Specified by:
clear
in interfaceListenerManager<K,V>
-
size
public int size()
Description copied from interface:ListenerManager
Return the number of listeners- Specified by:
size
in interfaceListenerManager<K,V>
- Returns:
- number
-
forEach
public void forEach(Consumer<V> function)
Description copied from interface:ListenerManager
Utility - apply the given function to each listener. The function receives the listener as an argument.- Specified by:
forEach
in interfaceListenerManager<K,V>
- Parameters:
function
- function to call for each listener
-
-