Package com.github.tadukoo.util.event
Class EventHandler<EventType extends Event,Listener extends EventListener<EventType>>
java.lang.Object
com.github.tadukoo.util.event.EventHandler<EventType,Listener>
- Type Parameters:
EventType- TheEventsubclass to handle events forListener- TheEventListenerimplementation to sendEventsto
public abstract class EventHandler<EventType extends Event,Listener extends EventListener<EventType>>
extends Object
An abstract class to handle the creation of
Events and send them out to the
various EventListeners to handle them appropriately.- Version:
- 0.1-Alpha-SNAPSHOT
- Author:
- Logan Ferree (Tadukoo)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanWhether this EventHandler is currently handlingEventsEventListenersto be added once the EventHandler is no longer in processEventListenersto be removed once the EventHandler is no longer in processThe registeredEventListenersto be notified ofEvents -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidregisterListener(Listener listener) Register aEventListenerso it will be notified ofEventshandled by this class.protected final voidSends the givenEventout to all of the registeredEventListeners.final voidunregisterListener(Listener listener) Unregisters aEventListenerso it will no longer be notified aboutEventshandled by this class.
-
Field Details
-
listeners
The registeredEventListenersto be notified ofEvents -
inProcess
private boolean inProcessWhether this EventHandler is currently handlingEvents -
listenerAddQueue
EventListenersto be added once the EventHandler is no longer in process -
listenerRemoveQueue
EventListenersto be removed once the EventHandler is no longer in process
-
-
Constructor Details
-
EventHandler
public EventHandler()
-
-
Method Details
-
registerListener
Register aEventListenerso it will be notified ofEventshandled by this class.- Parameters:
listener- The EventListener to register
-
unregisterListener
Unregisters aEventListenerso it will no longer be notified aboutEventshandled by this class.- Parameters:
listener- The EventListener to unregister
-
sendEventToListeners
Sends the givenEventout to all of the registeredEventListeners.- Parameters:
e- The Event to send out
-