IntegerType.java

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

  2. import java.util.function.Function;

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

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

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

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

  31. }