Package org.djutils.event
Class AbstractEvent
- java.lang.Object
-
- org.djutils.event.AbstractEvent
-
- All Implemented Interfaces:
Serializable
,EventInterface
- Direct Known Subclasses:
Event
,TimedEvent
public class AbstractEvent extends Object implements EventInterface
The Event class forms the reference implementation for the EventInterface. Because events are often sent over the network, the interface demands that source of the event and its content are serializable. It is the responsibility of the programmer, though, that the fields of the sourceId and content are serializable as well.Copyright (c) 2002-2021 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 Summary
Constructors Constructor Description AbstractEvent(EventTypeInterface type, Serializable sourceId, Serializable content)
Construct a new Event, where compliance with the metadata is verified.AbstractEvent(EventTypeInterface type, Serializable sourceId, Serializable content, boolean verifyMetaData)
Construct a new Event, with a choice to verify compliance with metadata.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
Serializable
getContent()
Return the content (payload) of this event.Serializable
getSourceId()
Return the id of the source of the event.EventTypeInterface
getType()
Return the type of the event.int
hashCode()
-
-
-
Constructor Detail
-
AbstractEvent
public AbstractEvent(EventTypeInterface type, Serializable sourceId, Serializable content)
Construct a new Event, where compliance with the metadata is verified.- Parameters:
type
- EventTypeInterface; the name of the Event.sourceId
- Serializable; the source id of the sendercontent
- Serializable; the content of the event
-
AbstractEvent
public AbstractEvent(EventTypeInterface type, Serializable sourceId, Serializable content, boolean verifyMetaData)
Construct a new Event, with a choice to verify compliance with metadata.- Parameters:
type
- EventTypeInterface; the name of the Event.sourceId
- Serializable; the source id of the sendercontent
- Serializable; the content of the eventverifyMetaData
- boolean; whether to verify the compliance with metadata or not
-
-
Method Detail
-
getSourceId
public final Serializable getSourceId()
Return the id of the source of the event. The source is, or identifies the sender of the event- Specified by:
getSourceId
in interfaceEventInterface
- Returns:
- Serializable; the id of the source of the event
-
getContent
public final Serializable getContent()
Return the content (payload) of this event.- Specified by:
getContent
in interfaceEventInterface
- Returns:
- Serializable; the content (payload) of this event
-
getType
public EventTypeInterface getType()
Return the type of the event.- Specified by:
getType
in interfaceEventInterface
- Returns:
- EventTypeInterface; the type of the event
-
-