NullHistorical.java

  1. package org.opentrafficsim.core.perception;

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

  3. /**
  4.  * Simple implementation without history that can be used inside a generic context where also implementations with history can
  5.  * be used.
  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/node/13">OpenTrafficSim License</a>.
  9.  * <p>
  10.  * @version $Revision$, $LastChangedDate$, by $Author$, initial version 1 feb. 2018 <br>
  11.  * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
  12.  * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
  13.  * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
  14.  * @param <T> value type
  15.  */
  16. public class NullHistorical<T> implements Historical<T>
  17. {

  18.     /** Value. */
  19.     private T val;

  20.     /**
  21.      * Constructor.
  22.      * @param value T; value
  23.      */
  24.     public NullHistorical(final T value)
  25.     {
  26.         this.val = value;
  27.     }

  28.     /** {@inheritDoc} */
  29.     @Override
  30.     public void set(final T value)
  31.     {
  32.         this.val = value;
  33.     }

  34.     /** {@inheritDoc} */
  35.     @Override
  36.     public T get()
  37.     {
  38.         return this.val;
  39.     }

  40.     /** {@inheritDoc} */
  41.     @Override
  42.     public T get(final Time time)
  43.     {
  44.         return this.val;
  45.     }

  46.     /** {@inheritDoc} */
  47.     @Override
  48.     public String toString()
  49.     {
  50.         return "NullHistorical [val=" + this.val + "]";
  51.     }

  52. }