Package com.jgcomptech.tools.events
Class EventTarget<T extends Event>
- java.lang.Object
-
- com.jgcomptech.tools.events.EventTarget<T>
-
- Type Parameters:
T- the event type to use for the target
- Direct Known Subclasses:
Permission,PermissionManager,SessionManager
public class EventTarget<T extends Event> extends java.lang.ObjectAllows object event handler registration and forwards received events to the appropriate registered event handlers.- Since:
- 1.4.0
-
-
Constructor Summary
Constructors Constructor Description EventTarget()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddEventHandler(EventType<? extends Event> eventType, EventHandler<T> eventHandler)Sets the specified singleton handler.booleanequals(java.lang.Object o)voidfire(Event event, EventType<? extends Event> eventType)Fires the handle method in all registered EventHandlers.EventHandler<T>getEventHandler(EventType<? extends T> eventType)Returns the singleton handler assigned to the specified Event Type.inthashCode()voidremoveEventHandler(EventType<? extends T> eventType)Removes the singleton handler assigned to the specified Event Type.java.lang.StringtoString()
-
-
-
Method Detail
-
addEventHandler
public final void addEventHandler(EventType<? extends Event> eventType, EventHandler<T> eventHandler)
Sets the specified singleton handler. There can only be one such handler specified at a time.- Parameters:
eventType- the event type to associate with the given eventHandlereventHandler- the handler to register, or null to unregister
-
removeEventHandler
public final void removeEventHandler(EventType<? extends T> eventType)
Removes the singleton handler assigned to the specified Event Type.- Parameters:
eventType- the event type to associate with the given eventHandler
-
getEventHandler
public final EventHandler<T> getEventHandler(EventType<? extends T> eventType)
Returns the singleton handler assigned to the specified Event Type.- Parameters:
eventType- the event type- Returns:
- the singleton handler assigned to the specified Event Type
-
fire
public final void fire(Event event, EventType<? extends Event> eventType)
Fires the handle method in all registered EventHandlers.- Parameters:
event- the eventeventType- the event type
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-