ParameterTypeBoolean.java

  1. package org.opentrafficsim.base.parameters;

  2. import java.io.Serializable;

  3. /**
  4.  * Wrapper class for boolean 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://github.com/wjschakel">Wouter Schakel</a>
  11.  */
  12. public class ParameterTypeBoolean extends ParameterType<Boolean> implements Serializable
  13. {
  14.     /** */
  15.     private static final long serialVersionUID = 20160400L;

  16.     /**
  17.      * Construct a new ParameterTypeBoolean without default value.
  18.      * @param id String; short name of the new ParameterTypeBoolean
  19.      * @param description String; parameter description or full name of the new ParameterTypeBoolean
  20.      */
  21.     public ParameterTypeBoolean(final String id, final String description)
  22.     {
  23.         super(id, description, Boolean.class);
  24.     }

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

  35.     /** {@inheritDoc} */
  36.     @Override
  37.     public final String printValue(final Parameters parameters) throws ParameterException
  38.     {
  39.         return Boolean.toString(parameters.getParameter(this));
  40.     }

  41.     /** {@inheritDoc} */
  42.     @SuppressWarnings("checkstyle:designforextension")
  43.     @Override
  44.     public String toString()
  45.     {
  46.         return "ParameterTypeBoolean [id=" + getId() + ", description=" + getDescription() + "]";
  47.     }

  48. }