T - event typepublic class EventBus<T>
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
class |
EventBus.EventBinder<E extends T> |
protected class |
EventBus.EventListenerNode |
protected static class |
EventBus.TypedEventListener<E extends T,T>
A wrapper for an event listener that only accepts a specific type of
event.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
PRIORITY_DEFAULT |
static int |
PRIORITY_HIGH |
static int |
PRIORITY_LOW |
protected java.util.List<EventBus.EventListenerNode> |
unsortedListeners |
| Constructor and Description |
|---|
EventBus() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
buildCache()
Builds an ordered list cachedListeners.
|
void |
clear() |
int |
count() |
protected java.util.List<EventBus.EventListenerNode> |
getSortedListeners()
Retrieves the sorted listeners.
|
protected void |
invalidateCache()
Invalidates the sorted listeners.
|
boolean |
isEmpty()
Checks if there are any listeners in this list.
|
<E extends T> |
on()
Retrieves the EventBinder object to bind an EventListener to ths EventBus that only accepts a specific subclass of <T>
|
<E extends T> |
on(java.lang.Class<E> clazz) |
void |
publish(T event)
Publishes an event by calling all of the registered listeners.
|
boolean |
remove(EventListener<T> listener)
Removes an EventListener from the list.
|
public static final int PRIORITY_HIGH
public static final int PRIORITY_DEFAULT
public static final int PRIORITY_LOW
protected final java.util.List<EventBus.EventListenerNode> unsortedListeners
protected void buildCache()
protected void invalidateCache()
protected java.util.List<EventBus.EventListenerNode> getSortedListeners()
public void clear()
public boolean remove(EventListener<T> listener)
listener - listener to be removedpublic boolean isEmpty()
public int count()
public void publish(T event)
event - event to be publishedpublic <E extends T> EventBus.EventBinder<E> on()
E - The event typepublic <E extends T> EventBus.EventBinder<E> on(java.lang.Class<E> clazz)