Package org.apache.wicket.util.listener
Class ListenerCollection<T>
- java.lang.Object
-
- org.apache.wicket.util.listener.ListenerCollection<T>
-
- Type Parameters:
T
- type of listeners
- All Implemented Interfaces:
Serializable
,Iterable<T>
- Direct Known Subclasses:
AjaxRequestTargetListenerCollection
,ApplicationListenerCollection
,BehaviorInstantiationListenerCollection
,ChangeListenerSet
,ComponentInitializationListenerCollection
,ComponentInstantiationListenerCollection
,ComponentOnAfterRenderListenerCollection
,ComponentOnBeforeRenderListenerCollection
,ComponentOnConfigureListenerCollection
,HeaderContributorListenerCollection
,OnComponentTagListenerCollection
,RequestCycleListenerCollection
,SessionListenerCollection
public abstract class ListenerCollection<T> extends Object implements Serializable, Iterable<T>
Represents a collection of listeners. Facilitates invocation of events on each listener.Listeners will be invoked in the order added to the collection when using
notify(INotifier)
or in reversed order when usingreversedNotify(INotifier)
.- Author:
- ivaynberg (Igor Vaynberg), Jonathan Locke
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static interface
ListenerCollection.INotifier<T>
Used to notify a listener.
-
Constructor Summary
Constructors Constructor Description ListenerCollection()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(T listener)
Adds a listener to this set of listeners.protected boolean
isAllowingDuplicates()
Whether or not added listeners should be checked for duplicates.protected boolean
isAllowingNulls()
Whether or not to allownull
s in listener collection.Iterator<T>
iterator()
Returns an iterator that can iterate the listeners.protected void
notify(ListenerCollection.INotifier<T> notifier)
Notifies each listener in thisprotected void
notifyIgnoringExceptions(ListenerCollection.INotifier<T> notifier)
Notifies each listener in this set ignoring exceptions.void
remove(T listener)
Removes a listener from this set.protected void
reversedNotify(ListenerCollection.INotifier<T> notifier)
Notifies each listener in this in reversed orderprotected void
reversedNotifyIgnoringExceptions(ListenerCollection.INotifier<T> notifier)
Notifies each listener in this set in reverse order ignoring exceptions-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
ListenerCollection
public ListenerCollection()
-
-
Method Detail
-
add
public boolean add(T listener)
Adds a listener to this set of listeners.- Parameters:
listener
- The listener to add- Returns:
true
if the listener was added
-
notify
protected void notify(ListenerCollection.INotifier<T> notifier)
Notifies each listener in this- Parameters:
notifier
- notifier used to notify each listener
-
notifyIgnoringExceptions
protected void notifyIgnoringExceptions(ListenerCollection.INotifier<T> notifier)
Notifies each listener in this set ignoring exceptions. Exceptions will be logged.- Parameters:
notifier
- notifier used to notify each listener
-
reversedNotifyIgnoringExceptions
protected void reversedNotifyIgnoringExceptions(ListenerCollection.INotifier<T> notifier)
Notifies each listener in this set in reverse order ignoring exceptions- Parameters:
notifier
- notifier used to notify each listener
-
reversedNotify
protected void reversedNotify(ListenerCollection.INotifier<T> notifier)
Notifies each listener in this in reversed order- Parameters:
notifier
- notifier used to notify each listener
-
remove
public void remove(T listener)
Removes a listener from this set.- Parameters:
listener
- The listener to remove
-
isAllowingDuplicates
protected boolean isAllowingDuplicates()
Whether or not added listeners should be checked for duplicates.- Returns:
true
to ignore duplicates
-
isAllowingNulls
protected boolean isAllowingNulls()
Whether or not to allownull
s in listener collection.- Returns:
- true to allow nulls to be added to the collection
-
-