AccelerationType.java

  1. package org.opentrafficsim.xml.bindings.types;

  2. import java.util.function.Function;

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

  4. /**
  5.  * Expression type with Acceleration value.
  6.  * <p>
  7.  * Copyright (c) 2023-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/wjschakel">Wouter Schakel</a>
  11.  */
  12. public class AccelerationType extends ExpressionType<Acceleration>
  13. {

  14.     /** Function to convert output from expression to the right type. */
  15.     private static final Function<Object, Acceleration> TO_TYPE = (o) -> Acceleration.instantiateSI(((Number) o).doubleValue());

  16.     /**
  17.      * Constructor with value.
  18.      * @param value Acceleration; value, may be {@code null}.
  19.      */
  20.     public AccelerationType(final Acceleration value)
  21.     {
  22.         super(value, TO_TYPE);
  23.     }

  24.     /**
  25.      * Constructor with expression.
  26.      * @param expression String; expression.
  27.      */
  28.     public AccelerationType(final String expression)
  29.     {
  30.         super(expression, TO_TYPE);
  31.     }

  32. }