LongType.java

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

  2. import java.util.function.Function;

  3. /**
  4.  * Expression type with Long value.
  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 LongType extends ExpressionType<Long>
  12. {

  13.     /** Function to convert output from expression to the right type. */
  14.     private static final Function<Object, Long> TO_TYPE = (o) -> ((Number) o).longValue();
  15.    
  16.     /**
  17.      * Constructor with value.
  18.      * @param value Long; value, may be {@code null}.
  19.      */
  20.     public LongType(final Long value)
  21.     {
  22.         super(value, TO_TYPE);
  23.     }

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

  32. }