Package org.djutils.event
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:
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:
- The object extending the EventProducer does not have to be Serializable itself
- There is no risk that the entire EventProducer object gets serialized (including subclasses) and is sent over the network
- 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 Summary
Modifier and Type Method Description Serializable
getContent()
Return the content (payload) of this event.Serializable
getSourceId()
Return the id of the source of the event.EventType
getType()
Return the type of the event.
-
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
-