Class ParameterType<T>

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected T defaultValue
      Default value.
    • Constructor Summary

      Constructors 
      Constructor Description
      ParameterType​(java.lang.String id, java.lang.String description, java.lang.Class<T> valueClass)
      Construct a new AbstractParameterType without default value and constraint.
      ParameterType​(java.lang.String id, java.lang.String description, java.lang.Class<T> valueClass, Constraint<? super T> constraint)
      Construct a new AbstractParameterType without default value and with constraint.
      ParameterType​(java.lang.String id, java.lang.String description, java.lang.Class<T> valueClass, T defaultValue)
      Construct a new AbstractParameterType with default value, without constraint.
      ParameterType​(java.lang.String id, java.lang.String description, java.lang.Class<T> valueClass, T defaultValue, Constraint<? super T> constraint)
      Construct a new AbstractParameterType with default value and constraint.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void check​(T value, Parameters params)
      Default implementation of check method.
      void checkConstraint​(T value)
      Check that a value complies with the constraint of this AbstractParameterType.
      boolean equals​(java.lang.Object obj)
      Constraint<? super T> getConstraint()
      Retrieve the constraint.
      T getDefaultValue()
      Retrieve the the default value of this AbstractParameterType.
      java.lang.String getDescription()
      Retrieve the description of this AbstractParameterType.
      java.lang.String getId()
      Retrieve the id of this AbstractParameterType.
      java.lang.Class<T> getValueClass()
      Retrieve the class of the value of this AbstractParameterType.
      boolean hasDefaultValue()
      Returns whether this parameter type has a default value.
      int hashCode()
      java.lang.String printValue​(Parameters parameters)
      Print the given value from the map in Parameters in a presentable format.
      java.lang.String toString()
      • Methods inherited from class org.opentrafficsim.base.Type

        isType
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • defaultValue

        protected final T defaultValue
        Default value.
    • Constructor Detail

      • ParameterType

        public ParameterType​(java.lang.String id,
                             java.lang.String description,
                             java.lang.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​(java.lang.String id,
                             java.lang.String description,
                             java.lang.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​(java.lang.String id,
                             java.lang.String description,
                             java.lang.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​(java.lang.String id,
                             java.lang.String description,
                             java.lang.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 Detail

      • getId

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

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

        public final java.lang.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 java.lang.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 java.lang.Object
      • equals

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

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

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object