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 using reversedNotify(INotifier).

Author:
ivaynberg (Igor Vaynberg), Jonathan Locke
See Also:
  • Constructor Details

  • Method Details

    • 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

      Notifies each listener in this set ignoring exceptions. Exceptions will be logged.
      Parameters:
      notifier - notifier used to notify each listener
    • reversedNotifyIgnoringExceptions

      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 allow nulls in listener collection.
      Returns:
      true to allow nulls to be added to the collection
    • iterator

      public Iterator<T> iterator()
      Returns an iterator that can iterate the listeners.
      Specified by:
      iterator in interface Iterable<T>
      Returns:
      an iterator that can iterate the listeners.