Class EventType

  • All Implemented Interfaces:
    Serializable

    public class EventType
    extends Object
    implements Serializable
    Reference implementation of the EventType. The AbstractEventType is the description of a topic used for the subscription to asynchronous events. Event types are used by EventProducers to show which events they potentially fire. EventTypes are typically defined as static final fields. In order to prevent name clashes for the EventType, the full name of the class from which the EventType was defined (usually in the <clinit>) is added to the equals() and hashCode() methods of the EventType. In that way, EventTypes that are the same will be unique, but EventTypes with just the same name but defined in different classes will be different. This is the abstract class that can be tailored to any event type. Subclasses that extend the AbstractEventType are the EventType for regular events, and TimedEventType for timed events.

    Note: the reason why this is important is because remote events that use EventTypes can have multiple versions of the same public static final EventType: one the is defined in the client, and one that is defined via the network. These will have different addresses in memory but they share the same class and name info, so equals() will yield true.

    Copyright (c) 2002-2023 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djutils.org. The DJUTILS project is distributed under a three-clause BSD-style license, which can be found at https://djutils.org/docs/license.html. This class was originally part of the DSOL project, see https://simulation.tudelft.nl/dsol/manual.

    Author:
    Peter Jacobs , Alexander Verbraeck
    See Also:
    Serialized Form
    • Constructor Detail

      • EventType

        public EventType​(String name,
                         MetaData metaData)
        Construct a new EventType. Only events of the type Event, and no subclasses of Event, can be used to fire events of this type. This means that firing a TimedEvent of this type will result in an error.
        Parameters:
        name - String; the name of the new eventType. Two values are not appreciated: null and the empty string.
        metaData - MetaData; describes the payload of events of the new EventType;
      • EventType

        public EventType​(MetaData metaData)
        Construct a new EventType. The name of the metadata will function as the name of the event. Only events of the type Event, and no subclasses of Event, can be used to fire events of this type. This means that firing a TimedEvent of this type will result in an error.
        Parameters:
        metaData - MetaData; describes the payload of events of the new EventType;
      • EventType

        @Deprecated
        public EventType​(String name)
        Deprecated.
        Construct a new EventType with no meta data. Only events of the type Event, and no subclasses of Event, can be used to fire events of this type. This means that firing a TimedEvent of this type will result in an error.
        Parameters:
        name - String; the name of the new eventType. Two values are not appreciated: null and the empty string.
    • Method Detail

      • getName

        public String getName()
        Return the event type name.
        Returns:
        String; the event type name
      • getMetaData

        public MetaData getMetaData()
        Retrieve the MetaData that describes the payload of events of this EventType.
        Returns:
        MetaData; describes the payload of events of this EventType
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object