public class ListenerList<T>
extends java.lang.Object
implements java.lang.Iterable<T>
Object.equals(Object) method or the identity operator (==) can be used. Furthermore, this class
is thread-safe and no ConcurrentModificationExceptions are thrown when adding or removing
listeners while iterating the list.
This is list is neither serializable, nor does it override the Object.equals(Object) or
Object.hashCode() method.
| Modifier and Type | Class and Description |
|---|---|
static class |
ListenerList.CompareMethod
Contains all possible methods for comparing listeners with each other.
|
| Constructor and Description |
|---|
ListenerList()
Creates a new list, which is meant to be used for managing event listeners.
|
ListenerList(@NotNull ListenerList.CompareMethod compareMethod)
Creates a new list, which is meant to be used for managing event listeners.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(T listener)
Adds a new listener to the list.
|
void |
addAll(@NotNull java.lang.Iterable<? extends T> iterable)
Adds all listeners, which can be iterated using a specific iterable, to the list.
|
void |
clear()
Removes all listeners from the list.
|
@NotNull java.util.Collection<T> |
getAll()
Returns a collection, which contains all listeners, which are currently contained by the
list.
|
@NotNull ListenerList.CompareMethod |
getCompareMethod()
Returns the compare method, which is used by the list.
|
boolean |
isEmpty()
Returns, whether the list is empty, or not.
|
@NotNull java.util.Iterator<T> |
iterator() |
boolean |
remove(T listener)
Removes a specific listener from the list.
|
void |
removeAll(@NotNull java.lang.Iterable<? extends T> iterable)
Removes all listeners, which can be iterated using a specific iterable.
|
int |
size()
Returns the number of listeners, which are contained by the list.
|
public ListenerList()
Object.equals(Object) method.public ListenerList(@NotNull
@NotNull ListenerList.CompareMethod compareMethod)
compareMethod - The method, which should be used for comparing listeners to each other,
as a value of the enum ListenerList.CompareMethod. The compare method may not
be null@NotNull public final @NotNull ListenerList.CompareMethod getCompareMethod()
ListenerList.CompareMethod. The compare method may not be nullpublic final boolean isEmpty()
public final int size()
Integer valuepublic final boolean add(@NotNull
T listener)
listener - The listener, which should be added, as an instance of the generic type
T. The listener may not be nullpublic final void addAll(@NotNull
@NotNull java.lang.Iterable<? extends T> iterable)
iterable - The iterable as an instance of the type Iterable. The iterable may
not be nullpublic final boolean remove(@NotNull
T listener)
listener - The listener, which should be removed, as an instance of the generic type
T. The listener may not be nullpublic final void removeAll(@NotNull
@NotNull java.lang.Iterable<? extends T> iterable)
iterable - The iterable as an instance of the type Iterable. The iterable may
not be nullpublic final void clear()
@NotNull public @NotNull java.util.Collection<T> getAll()
Collection. The collection may not be null