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 java.lang.Object implements ListenerManager<K,V>
Upgraded version ofListenerContainerthat doesn't leak Guava's internals and also supports mapping/wrapping of listeners
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(K listener)Add the given listener.voidaddListener(K listener, java.util.concurrent.Executor executor)Add the given listener.voidclear()Remove all listenersvoidforEach(java.util.function.Consumer<V> function)Utility - apply the given function to each listener.static <K,V>
ListenerManager<K,V>mapping(java.util.function.Function<K,V> mapper)Returns a new container that wraps listeners using the given mappervoidremoveListener(K listener)Remove the given listenerintsize()Return the number of listeners
-
-
-
Method Detail
-
mapping
public static <K,V> ListenerManager<K,V> mapping(java.util.function.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:ListenableAdd the given listener. The listener will be executed in the containing instance's thread.- Specified by:
addListenerin interfaceListenable<K>- Parameters:
listener- listener to add
-
addListener
public void addListener(K listener, java.util.concurrent.Executor executor)
Description copied from interface:ListenableAdd the given listener. The listener will be executed using the given executor- Specified by:
addListenerin interfaceListenable<K>- Parameters:
listener- listener to addexecutor- executor to run listener in
-
removeListener
public void removeListener(K listener)
Description copied from interface:ListenableRemove the given listener- Specified by:
removeListenerin interfaceListenable<K>- Parameters:
listener- listener to remove
-
clear
public void clear()
Description copied from interface:ListenerManagerRemove all listeners- Specified by:
clearin interfaceListenerManager<K,V>
-
size
public int size()
Description copied from interface:ListenerManagerReturn the number of listeners- Specified by:
sizein interfaceListenerManager<K,V>- Returns:
- number
-
forEach
public void forEach(java.util.function.Consumer<V> function)
Description copied from interface:ListenerManagerUtility - apply the given function to each listener. The function receives the listener as an argument.- Specified by:
forEachin interfaceListenerManager<K,V>- Parameters:
function- function to call for each listener
-
-