Class ElementChangeListenerList
java.lang.Object
org.eclipse.handly.model.impl.support.ElementChangeListenerList
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
An entry of the element change listener list. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(IElementChangeListener listener, int eventMask) Adds the given element change listener for the specified event types to this list.void
clear()
Removes all listeners from this list.Returns the entries of this listener list.boolean
isEmpty()
Returns whether this listener list is empty.void
remove
(IElementChangeListener listener) Removes the given element change listener from this list.
-
Constructor Details
-
ElementChangeListenerList
public ElementChangeListenerList()
-
-
Method Details
-
add
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 (notnull
)eventMask
- the bit-wise OR of all event types of interest to the listener- See Also:
-
remove
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 (notnull
)- See Also:
-
getEntries
Returns the entries of this listener list. The returned array is unaffected by subsequentadds
orremoves
. 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, andfalse
otherwise
-
clear
public void clear()Removes all listeners from this list.
-