public abstract class AbstractListenerStore extends Object implements ListenerStore
ListenerStores.| Modifier and Type | Field and Description |
|---|---|
protected static int |
DEFAULT_SIZE_HINT
The default size hint for
createListenerList() |
| Constructor and Description |
|---|
AbstractListenerStore() |
| Modifier and Type | Method and Description |
|---|---|
<T extends Listener> |
add(T listener)
Adds the given object for all listener classes it implements.
|
protected <T extends Listener> |
copyList(Class<T> listenerClass,
Stream<Object> listeners,
int sizeHint)
Creates a collection from the given stream, casting each object to the
provided listener class.
|
protected <T> List<T> |
createListenerList()
Returns the List object to store listeners in.
|
protected abstract <T> List<T> |
createListenerList(int sizeHint)
Returns the List object to store listeners in.
|
<T extends Listener> |
remove(T listener)
Removes the given object for all listener classes it implements.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitadd, clearAll, clearAll, close, get, isSequential, remove, synchronizedViewprotected static final int DEFAULT_SIZE_HINT
createListenerList()protected abstract <T> List<T> createListenerList(int sizeHint)
T - Type of the resulting List.sizeHint - The expected initial size of the list to create.protected final <T> List<T> createListenerList()
T - Type of the resulting List.protected <T extends Listener> Collection<T> copyList(Class<T> listenerClass, Stream<Object> listeners, int sizeHint)
T - Type of the listeners in the given list.listenerClass - The class of the objects in the provided list.listeners - The stream to obtain the listeners for the resulting
collection from.sizeHint - Expected size of the input stream.public <T extends Listener> void add(T listener)
ListenerStoreAdds the given object for all listener classes it implements. This recursively traverses super classes and super interfaces of the given listener's class. When encountering a super interface X which
Listener.class butListener.class andListenerKind.TAGGINGthen the given listener will be registered for X. Otherwise, all super interfaces of X are processed in the same way. When all super interfaces have been processed, the same process is recursively applied to the super class of the given listener if it has one. The "otherwise" implies, that the inheritance hierarchy of classes which have already been recognized as target listener class will not be traversed. If the same listener class is encountered multiple times while traversing the hierarchy, the listener will still only be registered once for that class.
Note that for each class the listener is being added its
onRegister method is
called.
add in interface ListenerStoreT - Type of the listener.listener - The listener to add.public <T extends Listener> void remove(T listener)
ListenerStoreListenerStore.add(Listener) to learn how these classes are collected from the
given listener. If the same listener has been added multiple times for
the same listener class, only one reference will be removed. This is
compatible with the definition of ListenerStore.remove(Class, Listener), which
also only removes one reference of the listener.
Note that for each class the listener is being removed its
onUnregister method is
called.
remove in interface ListenerStoreT - Type of the listener.listener - The listener to remove.Copyright © 2014–2015. All rights reserved.