View Javadoc
1   package org.djutils.event;
2   
3   import java.io.Serializable;
4   
5   /**
6    * The EventInterface defines the a strongly typed event (using the EventType). The sender of the event can be identified,
7    * allowing for fine-grained filtering of events. Because events are often sent over the network, the interface demands that the
8    * event and its source id and content are serializable. It is the repsonsibility of the programmer, though, that the
9    * <b>content</b> of the object is serializable as well.<br>
10   * <br>
11   * In contrast with earlier implementations of the Event package, a <b>sourceId</b> is sent over the network rather than a
12   * pointer to the source itself. This has several advantages:
13   * <ol>
14   * <li>The object extending the EventProducer does not have to be Serializable itself</li>
15   * <li>There is no risk that the entire EventProducer object gets serialized (including subclasses) and is sent over the network
16   * <li>There is no risk that the receiver of an event gets a pointer to the sending object, while still being able to identify
17   * the sending object
18   * </ol>
19   * <p>
20   * Copyright (c) 2002-2020 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See
21   * for project information <a href="https://djutils.org" target="_blank"> https://djutils.org</a>. The DJUTILS project is
22   * distributed under a three-clause BSD-style license, which can be found at
23   * <a href="https://djutils.org/docs/license.html" target="_blank"> https://djutils.org/docs/license.html</a>. This class was
24   * originally part of the DSOL project, see <a href="https://simulation.tudelft.nl/dsol/manual" target="_blank">
25   * https://simulation.tudelft.nl/dsol/manual</a>.
26   * </p>
27   * @author <a href="https://www.linkedin.com/in/peterhmjacobs">Peter Jacobs </a>
28   * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
29   */
30  
31  public interface EventInterface extends Serializable
32  {
33  
34      /**
35       * Return the id of the source of the event. The source is, or identifies the sender of the event
36       * @return Serializable; the id of the source of the event
37       */
38      Serializable getSourceId();
39  
40      /**
41       * Return the content (payload) of this event.
42       * @return Serializable; the content (payload) of this event
43       */
44      Serializable getContent();
45  
46      /**
47       * Return the type of the event.
48       * @return EventType; the type of the event
49       */
50      EventType getType();
51      
52  }