View Javadoc
1   package org.opentrafficsim.base.parameters;
2   
3   import java.io.Serializable;
4   
5   import org.djunits.value.formatter.EngineeringFormatter;
6   import org.opentrafficsim.base.parameters.constraint.Constraint;
7   
8   /**
9    * Wrapper class for double parameters.
10   * <p>
11   * Copyright (c) 2013-2018 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
12   * BSD-style license. See <a href="http://opentrafficsim.org/docs/current/license.html">OpenTrafficSim License</a>.
13   * <p>
14   * @version $Revision$, $LastChangedDate$, by $Author$, initial version Apr 13, 2016 <br>
15   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
16   * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
17   */
18  public class ParameterTypeDouble extends ParameterTypeNumeric<Double> implements Serializable
19  {
20  
21      /** */
22      private static final long serialVersionUID = 120160400;
23  
24      /**
25       * Construct a new ParameterTypeDouble without default value and check.
26       * @param id String; short name of the new ParameterTypeDouble
27       * @param description String; parameter description or full name of the new ParameterTypeDouble
28       */
29      public ParameterTypeDouble(final String id, final String description)
30      {
31          super(id, description, Double.class);
32      }
33  
34      /**
35       * Construct a new ParameterTypeDouble with default value, without check.
36       * @param id String; short name of the new ParameterTypeDouble
37       * @param description String; parameter description or full name of the new ParameterTypeDouble
38       * @param defaultValue double; the default value of the new ParametertypeDouble
39       */
40      public ParameterTypeDouble(final String id, final String description, final double defaultValue)
41      {
42          super(id, description, Double.class, defaultValue);
43      }
44  
45      /**
46       * Construct a new ParameterTypeDouble without default value, with check.
47       * @param id String; short name of the new ParameterTypeDouble
48       * @param description String; parameter description or full name of the new ParameterTypeDouble
49       * @param constraint Constrain&lt;? super Double&gt;; constraint for parameter values
50       */
51      public ParameterTypeDouble(final String id, final String description, final Constraint<? super Double> constraint)
52      {
53          super(id, description, Double.class, constraint);
54      }
55  
56      /**
57       * Construct a new ParameterTypeDouble with default value and check.
58       * @param id String; short name of the new ParameterTypeDouble
59       * @param description String; parameter description or full name of the new ParameterTypeDouble
60       * @param defaultValue double; the default value of the new ParameterTypeDouble
61       * @param constraint Constraint&lt;? super Double&gt;; constraint for parameter values
62       */
63      public ParameterTypeDouble(final String id, final String description, final double defaultValue,
64              final Constraint<? super Double> constraint)
65      {
66          super(id, description, Double.class, defaultValue, constraint);
67      }
68  
69      /**
70       * Construct a new ParameterTypeDouble with default value and check.
71       * @param id String; short name of the new ParameterTypeDouble
72       * @param description String; parameter description or full name of the new ParameterTypeDouble
73       * @param defaultValue Double; default value for the new ParameterTypeDouble
74       * @param constraint Constraint&lt;Number&gt;; constraint for parameter values
75       */
76      public ParameterTypeDouble(final String id, final String description, final Double defaultValue,
77              final Constraint<Number> constraint)
78      {
79          super(id, description, Double.class, defaultValue, constraint);
80      }
81  
82      /** {@inheritDoc} */
83      @Override
84      public final String printValue(final Parameters parameters) throws ParameterException
85      {
86          return EngineeringFormatter.format(parameters.getParameter(this));
87      }
88  
89      /** {@inheritDoc} */
90      @SuppressWarnings("checkstyle:designforextension")
91      @Override
92      public String toString()
93      {
94          return "ParameterTypeDouble [id=" + getId() + ", description=" + getDescription() + "]";
95      }
96  
97  }