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
- TheEvent
subclass to handle events forListener
- TheEventListener
implementation to sendEvents
to
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
Modifier and TypeFieldDescriptionprivate boolean
Whether this EventHandler is currently handlingEvents
EventListeners
to be added once the EventHandler is no longer in processEventListeners
to be removed once the EventHandler is no longer in processThe registeredEventListeners
to be notified ofEvents
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
registerListener
(Listener listener) Register aEventListener
so it will be notified ofEvents
handled by this class.protected final void
Sends the givenEvent
out to all of the registeredEventListeners
.final void
unregisterListener
(Listener listener) Unregisters aEventListener
so it will no longer be notified aboutEvents
handled by this class.
-
Field Details
-
listeners
The registeredEventListeners
to be notified ofEvents
-
inProcess
private boolean inProcessWhether this EventHandler is currently handlingEvents
-
listenerAddQueue
EventListeners
to be added once the EventHandler is no longer in process -
listenerRemoveQueue
EventListeners
to be removed once the EventHandler is no longer in process
-
-
Constructor Details
-
EventHandler
public EventHandler()
-
-
Method Details
-
registerListener
Register aEventListener
so it will be notified ofEvents
handled by this class.- Parameters:
listener
- The EventListener to register
-
unregisterListener
Unregisters aEventListener
so it will no longer be notified aboutEvents
handled by this class.- Parameters:
listener
- The EventListener to unregister
-
sendEventToListeners
Sends the givenEvent
out to all of the registeredEventListeners
.- Parameters:
e
- The Event to send out
-