TimeStampedObject.java

  1. package org.opentrafficsim.base;

  2. import java.io.Serializable;

  3. import org.djunits.value.vdouble.scalar.Time;

  4. /**
  5.  * An object with a time stamp, where the object is of a specific class.
  6.  * <p>
  7.  * Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  8.  * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
  9.  * </p>
  10.  * $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $,
  11.  * initial version Jan 29, 2016 <br>
  12.  * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
  13.  * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
  14.  * @param <C> the time stamped object class.
  15.  */
  16. public class TimeStampedObject<C> implements Serializable
  17. {
  18.     /** */
  19.     private static final long serialVersionUID = 20160129L;

  20.     /** The object. */
  21.     private final C object;

  22.     /** The time stamp. */
  23.     private final Time timestamp;

  24.     /**
  25.      * Construct a new TimeStampedObject.
  26.      * @param object C; the object.
  27.      * @param timestamp Time; the time stamp.
  28.      */
  29.     public TimeStampedObject(final C object, final Time timestamp)
  30.     {
  31.         this.object = object;
  32.         this.timestamp = timestamp;
  33.     }

  34.     /**
  35.      * Retrieve the object.
  36.      * @return C; the object
  37.      */
  38.     public final C getObject()
  39.     {
  40.         return this.object;
  41.     }

  42.     /**
  43.      * Retrieve the time stamp.
  44.      * @return Time; the time stamp
  45.      */
  46.     public final Time getTimestamp()
  47.     {
  48.         return this.timestamp;
  49.     }

  50.     /** {@inheritDoc} */
  51.     @Override
  52.     public final String toString()
  53.     {
  54.         return "TimeStampedObject [object=" + this.object + ", timestamp=" + this.timestamp + "]";
  55.     }

  56. }