ParameterTypeString.java

  1. package org.opentrafficsim.base.parameters;

  2. import org.opentrafficsim.base.parameters.constraint.Constraint;

  3. /**
  4.  * Parameter type for {@code String} parameters.
  5.  * <p>
  6.  * Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  7.  * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
  8.  * <p>
  9.  * @version $Revision$, $LastChangedDate$, by $Author$, initial version 11 sep. 2017 <br>
  10.  * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
  11.  * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
  12.  * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
  13.  */

  14. public class ParameterTypeString extends ParameterType<String>
  15. {

  16.     /** */
  17.     private static final long serialVersionUID = 20170911L;

  18.     /**
  19.      * @param id String; short name of the new ParameterTypeString
  20.      * @param description String; description or full name of the new ParameterTypeString
  21.      */
  22.     public ParameterTypeString(final String id, final String description)
  23.     {
  24.         super(id, description, String.class);
  25.     }

  26.     /**
  27.      * @param id String; short name of the new ParameterTypeString
  28.      * @param description String; description or full name of the new ParameterTypeString
  29.      * @param defaultValue String; default value of the new ParameterTypeString
  30.      */
  31.     public ParameterTypeString(final String id, final String description, final String defaultValue)
  32.     {
  33.         super(id, description, String.class, defaultValue);
  34.     }

  35.     /**
  36.      * @param id String; short name of the new ParameterTypeString
  37.      * @param description String; description or full name of the new ParameterTypeString
  38.      * @param constraint Constraint&lt;? super String&gt;; constraint that applies to the value of the new ParameterTypeString
  39.      */
  40.     public ParameterTypeString(final String id, final String description, final Constraint<? super String> constraint)
  41.     {
  42.         super(id, description, String.class, constraint);
  43.     }

  44.     /**
  45.      * @param id String; short name of the new ParameterTypeString
  46.      * @param description String; description or full name of the new ParameterTypeString
  47.      * @param defaultValue String; default value of the new ParameterTypeString
  48.      * @param constraint Constraint&lt;? super String&gt;; constraint that applies to the value of the new ParameterTypeString
  49.      */
  50.     public ParameterTypeString(final String id, final String description, final String defaultValue,
  51.             final Constraint<? super String> constraint)
  52.     {
  53.         super(id, description, String.class, defaultValue, constraint);
  54.     }

  55.     /** {@inheritDoc} */
  56.     @Override
  57.     public final String printValue(final Parameters parameters) throws ParameterException
  58.     {
  59.         return parameters.getParameter(this);
  60.     }

  61.     /** {@inheritDoc} */
  62.     @SuppressWarnings("checkstyle:designforextension")
  63.     @Override
  64.     public String toString()
  65.     {
  66.         return "ParameterTypeString [id=" + getId() + ", description=" + getDescription() + "]";
  67.     }

  68. }