Class EventType<T extends Event>
- Type Parameters:
T
- the event associated with this type
- All Implemented Interfaces:
Serializable
A class representing an event type.
The events produced by Commons Configuration all have a specific type. The event type can be used to determine the meaning of a specific event. It also acts as filter criterion when event listeners are registered. The listener is then called only for events of this type or derived types. The events in this library form a natural hierarchy with base types and more specialized types. By specifying an appropriate event type at listener registration time, it can be determined on a fine-granular basis which events are propagated to the listener.
Note: Users familiar with JavaFX probably recognize this approach to event handling. It allows for generic event listener interfaces and a natural selection of events to be processed.
- Since:
- 2.0
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfetchSuperEventTypes
(EventType<?> eventType) Returns a set with all event types that are super types of the specified type.getName()
Gets the name of this event type.Gets the super event type.static boolean
isInstanceOf
(EventType<?> derivedType, EventType<?> baseType) Checks whether an event type is derived from another type.toString()
Returns a string representation for this object.
-
Constructor Details
-
EventType
Creates a new instance ofEventType
and initializes it with the super type and a type name. If no super type is specified, this is the root event type.- Parameters:
superEventType
- the super event typetypeName
- the name of this event type
-
-
Method Details
-
getSuperType
Gets the super event type. Result is null for the root event type.- Returns:
- the super event type
-
getName
Gets the name of this event type. The name has no specific semantic meaning. It is just used for debugging purposes and also part of the string representation of this event type.- Returns:
- the event type name
-
toString
Returns a string representation for this object. This method is mainly overridden for debugging purposes. The returned string contains the name of this event type. -
fetchSuperEventTypes
Returns a set with all event types that are super types of the specified type. This set contains the direct and indirect super types and also includes the given type itself. The passed in type may be null, then an empty set is returned.- Parameters:
eventType
- the event type in question- Returns:
- a set with all super event types
-
isInstanceOf
Checks whether an event type is derived from another type. This implementation tests whetherbaseType
is a direct or indirect super type ofderivedType
. If one of the types is null, result is false.- Parameters:
derivedType
- the derived event typebaseType
- the base event type- Returns:
- true if the derived type is an instance of the base type, false otherwise
-