Class 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 Summary
Fields Modifier and Type Field Description protected TdefaultValueDefault value. -
Constructor Summary
Constructors Constructor Description ParameterType(String id, String description, Class<T> valueClass)Construct a new AbstractParameterType without default value and constraint.ParameterType(String id, String description, Class<T> valueClass, Constraint<? super T> constraint)Construct a new AbstractParameterType without default value and with constraint.ParameterType(String id, String description, Class<T> valueClass, T defaultValue)Construct a new AbstractParameterType with default value, without constraint.ParameterType(String id, String description, Class<T> valueClass, T defaultValue, Constraint<? super T> constraint)Construct a new AbstractParameterType with default value and constraint. -
Method Summary
Modifier and Type Method Description voidcheck(T value, Parameters params)Default implementation of check method.voidcheckConstraint(T value)Check that a value complies with the constraint of this AbstractParameterType.booleanequals(Object obj)Constraint<? super T>getConstraint()Retrieve the constraint.TgetDefaultValue()Retrieve the the default value of this AbstractParameterType.StringgetDescription()Retrieve the description of this AbstractParameterType.StringgetId()Retrieve the id of this AbstractParameterType.Class<T>getValueClass()Retrieve the class of the value of this AbstractParameterType.booleanhasDefaultValue()Returns whether this parameter type has a default value.inthashCode()StringprintValue(Parameters parameters)Print the given value from the map in Parameters in a presentable format.StringtoString()
-
Field Details
-
defaultValue
Default value.
-
-
Constructor Details
-
ParameterType
Construct a new AbstractParameterType without default value and constraint.- Parameters:
id- String; short name of the new AbstractParameterTypedescription- String; description or full name of the new AbstractParameterTypevalueClass- 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 AbstractParameterTypedescription- String; description or full name of the new AbstractParameterTypevalueClass- Class<T>; class of the value of the new AbstractParameterTypeconstraint- Constraint<? super T>; constraint that applies to the value of the new AbstractParameterType
-
ParameterType
Construct a new AbstractParameterType with default value, without constraint.- Parameters:
id- String; short name of the new AbstractParameterTypedescription- String; description or full name of the new AbstractParameterTypevalueClass- Class<T>; class of the value of the new AbstractParameterTypedefaultValue- 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 AbstractParameterTypedescription- String; description or full name of the new AbstractParameterTypevalueClass- Class<T>; class of the value of the new AbstractParameterTypedefaultValue- T; default value of the new AbstractParameterTypeconstraint- Constraint<? super T>; constraint that applies to the value of the new AbstractParameterType
-
-
Method Details
-
getId
Retrieve the id of this AbstractParameterType.- Specified by:
getIdin interfaceIdentifiable- Returns:
- String; the id of this AbstractParameterType
-
getDescription
Retrieve the description of this AbstractParameterType.- Returns:
- String; the description of this AbstractParameterType
-
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
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
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
Default implementation of check method. This default implementation will never throw any Exception.- Parameters:
value- T; the value to checkparams- Parameters; Set of parameters to check- Throws:
ParameterException- If the value does not comply with constraints.
-
printValue
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() -
equals
-
getConstraint
Retrieve the constraint.- Returns:
- Constraint; the constraint of this AbstractParameterType
-
toString
-