DoubleAdapter.java

  1. package org.opentrafficsim.xml.bindings;

  2. import org.opentrafficsim.xml.bindings.types.DoubleType;

  3. /**
  4.  * Adapter for Double expression type.
  5.  * <p>
  6.  * Copyright (c) 2023-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  7.  * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
  8.  * </p>
  9.  * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
  10.  */
  11. public class DoubleAdapter extends ExpressionAdapter<Double, DoubleType>
  12. {

  13.     /** {@inheritDoc} */
  14.     @Override
  15.     public DoubleType unmarshal(final String field)
  16.     {
  17.         if (isExpression(field))
  18.         {
  19.             return new DoubleType(trimBrackets(field));
  20.         }
  21.         return new DoubleType(Double.valueOf(field));
  22.     }

  23. }