View Javadoc
1   package org.djutils.event;
2   
3   import java.io.Serializable;
4   
5   import org.djutils.metadata.MetaData;
6   
7   /**
8    * The EventTypeInteface is the description of a topic used for the subscription to asynchronous events. Event types are used by
9    * EventProducers to show which events they potentially fire. EventTypes are typically defined as static final fields. In order
10   * to prevent name clashes for the EventType, the full name of the class from which the EventType was defined (usually in the
11   * <clinit>) is added to the equals() and hashCode() methods of the EventType. In that way, EventTypes that are the same
12   * will be unique, but implementations of EventTypeInterface that have the same name but are defined in different classes will
13   * be different. This is the interface that all event types must implement. <br>
14   * <br>
15   * Note: the reason why this is important is because <b>remote events</b> that use EventTypes can have <i>multiple versions</i>
16   * of the same public static final EventType: one the is defined in the client, and one that is defined via the network. These
17   * will have <i>different addresses in memory</i> but they share the same class and name info, so equals() will yield true.
18   * <p>
19   * Copyright (c) 2002-2021 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See
20   * for project information <a href="https://djutils.org" target="_blank"> https://djutils.org</a>. The DJUTILS project is
21   * distributed under a three-clause BSD-style license, which can be found at
22   * <a href="https://djutils.org/docs/license.html" target="_blank"> https://djutils.org/docs/license.html</a>. This class was
23   * originally part of the DSOL project, see <a href="https://simulation.tudelft.nl/dsol/manual" target="_blank">
24   * https://simulation.tudelft.nl/dsol/manual</a>.
25   * </p>
26   * @author <a href="https://www.linkedin.com/in/peterhmjacobs">Peter Jacobs </a>
27   * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
28   */
29  public interface EventTypeInterface extends Serializable
30  {
31      /**
32       * Return the event type name.
33       * @return String; the event type name
34       */
35      String getName();
36  
37      /**
38       * Retrieve the MetaData that describes the payload of events of this EventType.
39       * @return MetaData; describes the payload of events of this EventType
40       */
41      MetaData getMetaData();
42  
43      /**
44       * Retrieve the event type that defines valid events of this EventType, e.g., to indicate a TimedEvent is expected.
45       * @return Class&lt;EventTypeInterface&gt;; the class of valid events of this event type
46       */
47      Class<? extends EventInterface> getValidEventType();
48  
49  }