Interface EventInterface

All Superinterfaces:
Serializable
All Known Implementing Classes:
Event, TimedEvent

public interface EventInterface
extends Serializable
The EventInterface defines the a strongly typed event (using the EventType). The sender of the event can be identified, allowing for fine-grained filtering of events. Because events are often sent over the network, the interface demands that the event and its source id and content are serializable. It is the repsonsibility of the programmer, though, that the content of the object is serializable as well.

In contrast with earlier implementations of the Event package, a sourceId is sent over the network rather than a pointer to the source itself. This has several advantages:
  1. The object extending the EventProducer does not have to be Serializable itself
  2. There is no risk that the entire EventProducer object gets serialized (including subclasses) and is sent over the network
  3. There is no risk that the receiver of an event gets a pointer to the sending object, while still being able to identify the sending object

Copyright (c) 2002-2020 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
  • Method Details

    • getSourceId

      Serializable getSourceId()
      Return the id of the source of the event. The source is, or identifies the sender of the event
      Returns:
      Serializable; the id of the source of the event
    • getContent

      Serializable getContent()
      Return the content (payload) of this event.
      Returns:
      Serializable; the content (payload) of this event
    • getType

      EventType getType()
      Return the type of the event.
      Returns:
      EventType; the type of the event