Class ElementChangeListenerList


  • public final class ElementChangeListenerList
    extends java.lang.Object
    A thread safe list of element change listeners.

    The implementation is optimized for minimal memory footprint, frequent reads and infrequent writes. Modification of the list is synchronized and relatively expensive, while accessing the listeners is very fast. Readers are given access to the underlying array data structure for reading, with the trust that they will not modify the underlying array.

    • Constructor Detail

      • ElementChangeListenerList

        public ElementChangeListenerList()
    • Method Detail

      • add

        public void add​(IElementChangeListener listener,
                        int eventMask)
        Adds the given element change listener for the specified event types to this list. Has no effect if an identical listener is already registered for these event types.

        After successful completion of this method, the given listener will be registered for exactly the specified event types. If it was previously registered for other event types, it will be de-registered for those event types.

        Parameters:
        listener - the listener to add (not null)
        eventMask - the bit-wise OR of all event types of interest to the listener
        See Also:
        remove(IElementChangeListener)
      • remove

        public void remove​(IElementChangeListener listener)
        Removes the given element change listener from this list. Has no effect if an identical listener is not registered.
        Parameters:
        listener - the listener to remove (not null)
        See Also:
        add(IElementChangeListener, int)
      • getEntries

        public ElementChangeListenerList.Entry[] getEntries()
        Returns the entries of this listener list. The returned array is unaffected by subsequent adds or removes. Use this method when notifying listeners, so that any modifications to the listener list during the notification will have no effect on the notification itself.
        Returns:
        the listener list entries (never null). Clients must not modify the returned array.
      • isEmpty

        public boolean isEmpty()
        Returns whether this listener list is empty.
        Returns:
        true if there are no registered listeners, and false otherwise
      • clear

        public void clear()
        Removes all listeners from this list.