Class ListenerCollection<T>

  • Type Parameters:
    T - type of listeners
    All Implemented Interfaces:
    java.io.Serializable, java.lang.Iterable<T>
    Direct Known Subclasses:
    ChangeListenerSet

    public abstract class ListenerCollection<T>
    extends java.lang.Object
    implements java.io.Serializable, java.lang.Iterable<T>
    Represents a collection of listeners. Facilitates invocation of events on each listener.

    NOTE: Ordering of listeners is not guaranteed and should not be relied upon

    Author:
    ivaynberg (Igor Vaynberg), Jonathan Locke
    See Also:
    Serialized Form
    • 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 allow nulls in listener collection.
        Returns:
        true to allow nulls to be added to the collection
      • iterator

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