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:
Serializable

public class EventType<T extends Event> extends Object implements 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 Details

    • EventType

      public EventType(EventType<? super T> superEventType, String typeName)
      Creates a new instance of EventType 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 type
      typeName - the name of this event type
  • Method Details

    • getSuperType

      public EventType<? super T> getSuperType()
      Gets the super event type. Result is null for the root event type.
      Returns:
      the super event type
    • getName

      public 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
    • toString

      public 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 class Object
      Returns:
      a string for this object
    • fetchSuperEventTypes

      public static 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 whether baseType is a direct or indirect super type of derivedType. If one of the types is null, result is false.
      Parameters:
      derivedType - the derived event type
      baseType - the base event type
      Returns:
      true if the derived type is an instance of the base type, false otherwise