Package repast.simphony.parameter
Class DefaultParameterSchema
java.lang.Object
repast.simphony.parameter.DefaultParameterSchema
- All Implemented Interfaces:
ParameterSchema
Default implementation of ParameterSchema.
- Author:
- Nick Collier
-
Constructor Summary
ConstructorDescriptionDefaultParameterSchema
(String name, Class type, Object defValue) DefaultParameterSchema
(String name, Class type, Object defValue, List possibleValues) DefaultParameterSchema
(String name, Class type, Object defValue, SteppedRange constrainingRange) -
Method Summary
Modifier and TypeMethodDescriptionfromString
(String str) Creates an Object from the String representation.Gets the list of values that constrain this parameter.Gets the numeric range of values that constrain this parameter.Gets the string representation of the values or range that constrain this parameter This will return an empty string if the parameter is not constrained (by a list or range)Gets the StringConverter if any.Gets the default value of the parameter.getName()
Gets the name of the parameter that this is the schema for.getType()
Gets the type of the parameter.void
setConstrainingList
(List list) Sets the constraining list.void
setConstrainingRange
(SteppedRange range) Sets the constraining range.void
setConvertor
(StringConverter converter) Sets the converter for this schema.void
setDefaultValue
(Object obj) Sets the default value of this parameter.Converts the object into a String representation.boolean
Validates the specified object against the type and optional constraint info for the parameter name.
-
Constructor Details
-
DefaultParameterSchema
-
DefaultParameterSchema
-
DefaultParameterSchema
-
DefaultParameterSchema
public DefaultParameterSchema(String name, Class type, Object defValue, SteppedRange constrainingRange)
-
-
Method Details
-
getConverter
Gets the StringConverter if any.- Specified by:
getConverter
in interfaceParameterSchema
- Returns:
- the StringConverter
-
setConvertor
Sets the converter for this schema.- Parameters:
converter
- the converter
-
getName
Gets the name of the parameter that this is the schema for.- Specified by:
getName
in interfaceParameterSchema
- Returns:
- the name of the parameter that this is the schema for.
-
getType
Gets the type of the parameter.- Specified by:
getType
in interfaceParameterSchema
- Returns:
- the type of the parameter.
-
getDefaultValue
Gets the default value of the parameter.- Specified by:
getDefaultValue
in interfaceParameterSchema
- Returns:
- the default value of the parameter.
-
setDefaultValue
Sets the default value of this parameter.- Specified by:
setDefaultValue
in interfaceParameterSchema
- Parameters:
obj
- the new default value
-
setConstrainingList
Sets the constraining list.- Parameters:
list
- the constraining list
-
setConstrainingRange
Sets the constraining range.- Parameters:
range
- the constraining range.
-
getConstrainingRange
Gets the numeric range of values that constrain this parameter. This will return null if the parameter is unconstrained by a numeric range.- Specified by:
getConstrainingRange
in interfaceParameterSchema
- Returns:
- the numeric range of values that constrain this parameter or null if the parameter is unconstrained by a range.
-
getConstrainingList
Gets the list of values that constrain this parameter. This will return null if the parameter is unconstrained by a list.- Specified by:
getConstrainingList
in interfaceParameterSchema
- Returns:
- the list of values that constrain this parameter or null if the parameter is unconstrained by a list of possible values.
-
getConstraintString
Gets the string representation of the values or range that constrain this parameter This will return an empty string if the parameter is not constrained (by a list or range)- Specified by:
getConstraintString
in interfaceParameterSchema
- Returns:
- the string representation of the parameter constraints, if unconstrained an empty string
-
validate
Validates the specified object against the type and optional constraint info for the parameter name.- Specified by:
validate
in interfaceParameterSchema
- Parameters:
obj
- the object to validate- Returns:
- true if the object is of a type valid for the parameter, otherwise false.
-
toString
Description copied from interface:ParameterSchema
Converts the object into a String representation.- Specified by:
toString
in interfaceParameterSchema
- Parameters:
obj
- the object to convert- Returns:
- the String representation.
-
fromString
Description copied from interface:ParameterSchema
Creates an Object from the String representation.- Specified by:
fromString
in interfaceParameterSchema
- Parameters:
str
- the String representation- Returns:
- the created Object
-