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-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/averbraeck">Alexander Verbraeck</a>
  10.  * @author <a href="https://tudelft.nl/staff/p.knoppers-1">Peter Knoppers</a>
  11.  * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
  12.  */

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

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

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

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

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

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

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

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

  67. }