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-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  8.  * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
  9.  * </p>
  10.  * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
  11.  * @author <a href="https://tudelft.nl/staff/p.knoppers-1">Peter Knoppers</a>
  12.  * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
  13.  * @param <T> value type
  14.  */
  15. public class NullHistorical<T> implements Historical<T>
  16. {

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

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

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

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

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

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

  51. }