Package org.djutils.event
Class TimedEvent<T extends Comparable<T> & Serializable>
- java.lang.Object
-
- org.djutils.event.AbstractEvent
-
- org.djutils.event.TimedEvent<T>
-
- Type Parameters:
T
- the Comparable type that represents time
- All Implemented Interfaces:
Serializable
,Comparable<TimedEvent<T>>
,EventInterface
,TimedEventInterface<T>
public class TimedEvent<T extends Comparable<T> & Serializable> extends AbstractEvent implements Comparable<TimedEvent<T>>, TimedEventInterface<T>
The TimedEvent is the reference implementation for a timed event. Because events are often sent over the network, the interface demands that the event, its sourceId, content and timestamp are serializable. It is the repsonsibility of the programmer, though, that the fields of the sourceId, content and timestamp 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 TimedEvent(TimedEventTypeInterface type, Serializable sourceId, Serializable content, T timeStamp)
Construct a new timed event, where compliance with the metadata is verified.TimedEvent(TimedEventTypeInterface type, Serializable sourceId, Serializable content, T timeStamp, boolean verifyMetaData)
Construct a new timed event, with a choice to verify compliance with metadata.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(TimedEvent<T> o)
boolean
equals(Object obj)
T
getTimeStamp()
Returns the timeStamp of this event.TimedEventTypeInterface
getType()
Return the type of the event.int
hashCode()
String
toString()
-
Methods inherited from class org.djutils.event.AbstractEvent
getContent, getSourceId
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.djutils.event.EventInterface
getContent, getSourceId
-
-
-
-
Constructor Detail
-
TimedEvent
public TimedEvent(TimedEventTypeInterface type, Serializable sourceId, Serializable content, T timeStamp)
Construct a new timed event, where compliance with the metadata is verified.- Parameters:
type
- TimedEventTypeInterface; the eventType of the event.sourceId
- Serializable; the source of the event.content
- Serializable; the content of the event.timeStamp
- T; the timeStamp.
-
TimedEvent
public TimedEvent(TimedEventTypeInterface type, Serializable sourceId, Serializable content, T timeStamp, boolean verifyMetaData)
Construct a new timed event, with a choice to verify compliance with metadata.- Parameters:
type
- TimedEventTypeInterface; the eventType of the event.sourceId
- Serializable; the source of the event.content
- Serializable; the content of the event.timeStamp
- T; the timeStamp.verifyMetaData
- boolean; whether to verify the compliance with metadata or not
-
-
Method Detail
-
getTimeStamp
public T getTimeStamp()
Returns the timeStamp of this event.- Specified by:
getTimeStamp
in interfaceTimedEventInterface<T extends Comparable<T> & Serializable>
- Returns:
- T; the time stamp
-
getType
public TimedEventTypeInterface getType()
Return the type of the event.- Specified by:
getType
in interfaceEventInterface
- Overrides:
getType
in classAbstractEvent
- Returns:
- EventTypeInterface; the type of the event
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classAbstractEvent
-
equals
public boolean equals(Object obj)
- Overrides:
equals
in classAbstractEvent
-
compareTo
public int compareTo(TimedEvent<T> o)
- Specified by:
compareTo
in interfaceComparable<T extends Comparable<T> & Serializable>
-
-