Package com.jgcomptech.tools.events
Class EventType<T extends Event>
- java.lang.Object
-
- com.jgcomptech.tools.events.EventType<T>
-
- Type Parameters:
T
- the event class to which this type applies
public final class EventType<T extends Event> extends java.lang.Object
This class represents a specific event type associated with anEvent
.Event types form a hierarchy with the
ROOT
(equals toEvent.ANY
) as its root. This is useful in event handler registration where a single event handler can be registered to a super event type and will be receiving its sub type events as well. Note that you cannot construct two different EventType objects with the same name and parent.- Since:
- 1.4.0
-
-
Constructor Summary
Constructors Constructor Description EventType(EventType<? super T> superType)
Constructs a newEventType
with the specified super type and the name set tonull
.EventType(EventType<? super T> superType, java.lang.String name)
Constructs a newEventType
with the specified super type and name.EventType(java.lang.String name)
Constructs a newEventType
with the specified name and theEventType.ROOT
as its super type.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EventType<T>
createSubType(java.lang.String name)
java.lang.String
getName()
Gets the name of this event type.EventType<? super T>
getSuperType()
Gets the super type of this event type.java.lang.String
toString()
Returns a string representation of thisEventType
object.
-
-
-
Constructor Detail
-
EventType
public EventType(java.lang.String name)
Constructs a newEventType
with the specified name and theEventType.ROOT
as its super type.
-
EventType
public EventType(EventType<? super T> superType)
Constructs a newEventType
with the specified super type and the name set tonull
.- Parameters:
superType
- the event super type- Throws:
java.lang.IllegalArgumentException
- if an EventType with "null" name and under this supertype exists
-
EventType
public EventType(EventType<? super T> superType, java.lang.String name)
Constructs a newEventType
with the specified super type and name.- Parameters:
superType
- the event super typename
- the name- Throws:
java.lang.IllegalArgumentException
- if an EventType with the same name and superType exists
-
-
Method Detail
-
getSuperType
public EventType<? super T> getSuperType()
Gets the super type of this event type. The returned value isnull
only for theEventType.ROOT
.- Returns:
- the super type
-
getName
public java.lang.String getName()
Gets the name of this event type.- Returns:
- the name
-
toString
public java.lang.String toString()
Returns a string representation of thisEventType
object.- Overrides:
toString
in classjava.lang.Object
- Returns:
- a string representation of this
EventType
object.
-
-