Class EventType<T extends Event>
- java.lang.Object
-
- org.apache.commons.configuration2.event.EventType<T>
-
- Type Parameters:
T
- the event associated with this type
- All Implemented Interfaces:
java.io.Serializable
public class EventType<T extends Event> extends java.lang.Object implements java.io.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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
FMT_TO_STRING
Constant for the format used by toString().private java.lang.String
name
A name for this event type.private static long
serialVersionUID
Serial version UID.private EventType<? super T>
superType
Stores the super type of this type.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.util.Set<EventType<?>>
fetchSuperEventTypes(EventType<?> eventType)
Returns a set with all event types that are super types of the specified type.java.lang.String
getName()
Gets the name of this event type.EventType<? super T>
getSuperType()
Gets the super event type.static boolean
isInstanceOf(EventType<?> derivedType, EventType<?> baseType)
Checks whether an event type is derived from another type.java.lang.String
toString()
Returns a string representation for this object.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
Serial version UID.- See Also:
- Constant Field Values
-
FMT_TO_STRING
private static final java.lang.String FMT_TO_STRING
Constant for the format used by toString().- See Also:
- Constant Field Values
-
superType
private final EventType<? super T extends Event> superType
Stores the super type of this type.
-
name
private final java.lang.String name
A name for this event type.
-
-
Constructor Detail
-
EventType
public EventType(EventType<? super T> superEventType, java.lang.String typeName)
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 Detail
-
fetchSuperEventTypes
public static java.util.Set<EventType<?>> fetchSuperEventTypes(EventType<?> eventType)
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
public static boolean isInstanceOf(EventType<?> derivedType, EventType<?> baseType)
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
-
getName
public java.lang.String 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
-
getSuperType
public EventType<? super T> getSuperType()
Gets the super event type. Result is null for the root event type.- Returns:
- the super event type
-
toString
public java.lang.String 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.- Overrides:
toString
in classjava.lang.Object
- Returns:
- a string for this object
-
-