T - event typepublic class ListenerList<T>
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
protected class |
ListenerList.EventListenerNode |
| Modifier and Type | Field and Description |
|---|---|
protected ListenerList.EventListenerNode |
first |
protected ListenerList.EventListenerNode |
last |
static int |
PRIORITY_DEFAULT |
static int |
PRIORITY_HIGH |
static int |
PRIORITY_LOW |
| Constructor and Description |
|---|
ListenerList() |
| Modifier and Type | Method and Description |
|---|---|
void |
accept(Consumer<T> consumer)
Invokes the given consumer for every listener in the list.
|
ListenerHandle<T> |
add(T listener)
Adds an IEventListener to the list.
|
ListenerHandle<T> |
add(T listener,
int priority) |
void |
clear()
Clears this listener list.
|
boolean |
isEmpty()
Checks if there are any listeners in this list.
|
boolean |
remove(T listener)
Removes an IEventListener from the list.
|
public static final int PRIORITY_HIGH
public static final int PRIORITY_DEFAULT
public static final int PRIORITY_LOW
protected volatile ListenerList.EventListenerNode first
protected ListenerList.EventListenerNode last
public ListenerHandle<T> add(T listener)
listener - event listenerpublic ListenerHandle<T> add(T listener, int priority)
public boolean remove(T listener)
listener - listener to be removedpublic void clear()
public void accept(Consumer<T> consumer)
consumer - consumer to be called for each listenerpublic boolean isEmpty()