Class ElementChangeListenerList

java.lang.Object
org.eclipse.handly.model.impl.support.ElementChangeListenerList

public final class ElementChangeListenerList extends 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 Details

    • ElementChangeListenerList

      public ElementChangeListenerList()
  • Method Details

    • 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

      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:
    • 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.