T
- the event class to which this type appliespublic final class EventType<T extends Event>
extends java.lang.Object
implements java.io.Serializable
Event
.
Event types form a hierarchy with the ROOT
(equals to
Event.ANY
) as its root. This is useful in event filter / handler
registration where a single event filter / 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.
Note about deserialization: All EventTypes that are going to be deserialized
(e.g. as part of Event
deserialization), need to exist at the time of
deserialization. Deserialization of EventType will not create new EventType
objects.
Modifier and Type | Class and Description |
---|---|
(package private) static class |
EventType.EventTypeSerialization |
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
name |
static EventType<Event> |
ROOT
The root event type.
|
private java.util.WeakHashMap<EventType<? extends T>,java.lang.Void> |
subTypes |
private EventType<? super T> |
superType |
Constructor and Description |
---|
EventType()
Deprecated.
Do not use this constructor, as only one such EventType can exist
|
EventType(EventType<? super T> superType)
Constructs a new
EventType with the specified super type and
the name set to null . |
EventType(EventType<? super T> superType,
java.lang.String name)
Constructs a new
EventType with the specified super type and
name. |
EventType(java.lang.String name)
Constructs a new
EventType with the specified name and the
EventType.ROOT as its super type. |
EventType(java.lang.String name,
EventType<? super T> superType)
Internal constructor that skips various checks
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getName()
Gets the name of this event type.
|
EventType<? super T> |
getSuperType()
Gets the super type of this event type.
|
private void |
register(EventType<? extends T> subType) |
java.lang.String |
toString()
Returns a string representation of this
EventType object. |
private java.lang.Object |
writeReplace() |
public static final EventType<Event> ROOT
null
.private java.util.WeakHashMap<EventType<? extends T extends Event>,java.lang.Void> subTypes
private final java.lang.String name
@Deprecated public EventType()
EventType
with the EventType.ROOT
as its
super type and the name set to null
.public EventType(java.lang.String name)
EventType
with the specified name and the
EventType.ROOT
as its super type.public EventType(EventType<? super T> superType)
EventType
with the specified super type and
the name set to null
.superType
- the event super typejava.lang.IllegalArgumentException
- if an EventType with "null" name and
under this supertype existspublic EventType(EventType<? super T> superType, java.lang.String name)
EventType
with the specified super type and
name.superType
- the event super typename
- the namejava.lang.IllegalArgumentException
- if an EventType with the same name and
superType existspublic final EventType<? super T> getSuperType()
null
only for the EventType.ROOT
.public final java.lang.String getName()
public java.lang.String toString()
EventType
object.toString
in class java.lang.Object
EventType
object.private java.lang.Object writeReplace() throws java.io.ObjectStreamException
java.io.ObjectStreamException