Class ParameterType<T>

java.lang.Object
org.opentrafficsim.base.Type<ParameterType<T>>
org.opentrafficsim.base.parameters.ParameterType<T>
Type Parameters:
T - Type of the value.
All Implemented Interfaces:
Serializable, Identifiable
Direct Known Subclasses:
ParameterTypeBoolean, ParameterTypeClass, ParameterTypeClassList, ParameterTypeNumeric, ParameterTypeString

public class ParameterType<T>
extends Type<ParameterType<T>>
implements Serializable, Identifiable
Defines meta-information of a parameter, defining the parameter uniquely.

Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.

Version:
$Revision$, $LastChangedDate$, by $Author$, initial version Apr 13, 2016
Author:
Alexander Verbraeck, Wouter Schakel
See Also:
Serialized Form
  • Field Details

  • Constructor Details

    • ParameterType

      public ParameterType​(String id, String description, Class<T> valueClass)
      Construct a new AbstractParameterType without default value and constraint.
      Parameters:
      id - String; short name of the new AbstractParameterType
      description - String; description or full name of the new AbstractParameterType
      valueClass - Class<T>; class of the value of the new AbstractParameterType
    • ParameterType

      public ParameterType​(String id, String description, Class<T> valueClass, Constraint<? super T> constraint)
      Construct a new AbstractParameterType without default value and with constraint.
      Parameters:
      id - String; short name of the new AbstractParameterType
      description - String; description or full name of the new AbstractParameterType
      valueClass - Class<T>; class of the value of the new AbstractParameterType
      constraint - Constraint<? super T>; constraint that applies to the value of the new AbstractParameterType
    • ParameterType

      public ParameterType​(String id, String description, Class<T> valueClass, T defaultValue)
      Construct a new AbstractParameterType with default value, without constraint.
      Parameters:
      id - String; short name of the new AbstractParameterType
      description - String; description or full name of the new AbstractParameterType
      valueClass - Class<T>; class of the value of the new AbstractParameterType
      defaultValue - T; default value of the new AbstractParameterType
    • ParameterType

      public ParameterType​(String id, String description, Class<T> valueClass, T defaultValue, Constraint<? super T> constraint)
      Construct a new AbstractParameterType with default value and constraint.
      Parameters:
      id - String; short name of the new AbstractParameterType
      description - String; description or full name of the new AbstractParameterType
      valueClass - Class<T>; class of the value of the new AbstractParameterType
      defaultValue - T; default value of the new AbstractParameterType
      constraint - Constraint<? super T>; constraint that applies to the value of the new AbstractParameterType
  • Method Details

    • getId

      public final String getId()
      Retrieve the id of this AbstractParameterType.
      Specified by:
      getId in interface Identifiable
      Returns:
      String; the id of this AbstractParameterType
    • getDescription

      public final String getDescription()
      Retrieve the description of this AbstractParameterType.
      Returns:
      String; the description of this AbstractParameterType
    • getValueClass

      public final Class<T> getValueClass()
      Retrieve the class of the value of this AbstractParameterType.
      Returns:
      valueClass Class<T>; the class of the value of this AbstractParameterType
    • hasDefaultValue

      public final boolean hasDefaultValue()
      Returns whether this parameter type has a default value.
      Returns:
      boolean; true if this AbstractParameterType type has a default value; false if it does not have a default value
    • getDefaultValue

      public final T getDefaultValue() throws ParameterException
      Retrieve the the default value of this AbstractParameterType.
      Returns:
      T; the default value of this AbstractParameterType
      Throws:
      ParameterException - if this AbstractParameterType does not have a default value
    • checkConstraint

      public final void checkConstraint​(T value) throws ParameterException
      Check that a value complies with the constraint of this AbstractParameterType.
      Parameters:
      value - T; the value to check
      Throws:
      ParameterException - if the value does not comply with constraints
    • check

      public void check​(T value, Parameters params) throws ParameterException
      Default implementation of check method. This default implementation will never throw any Exception.
      Parameters:
      value - T; the value to check
      params - Parameters; Set of parameters to check
      Throws:
      ParameterException - If the value does not comply with constraints.
    • printValue

      public String printValue​(Parameters parameters) throws ParameterException
      Print the given value from the map in Parameters in a presentable format. The default implementation simply returns the output of toString().
      Parameters:
      parameters - Parameters; Parameters to get the value from
      Returns:
      String; readable representation of the value
      Throws:
      ParameterException - If the parameter is not present
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public final boolean equals​(Object obj)
      Overrides:
      equals in class Object
    • getConstraint

      public final Constraint<? super T> getConstraint()
      Retrieve the constraint.
      Returns:
      Constraint; the constraint of this AbstractParameterType
    • toString

      public String toString()
      Overrides:
      toString in class Object