Package repast.simphony.parameter
Class DefaultParameterSchema
- java.lang.Object
-
- repast.simphony.parameter.DefaultParameterSchema
-
- All Implemented Interfaces:
ParameterSchema
public class DefaultParameterSchema extends Object implements ParameterSchema
Default implementation of ParameterSchema.- Author:
- Nick Collier
-
-
Constructor Summary
Constructors Constructor Description DefaultParameterSchema(String name, Class type, Object defValue)
DefaultParameterSchema(String name, Class type, Object defValue, List possibleValues)
DefaultParameterSchema(String name, Class type, Object defValue, SteppedRange constrainingRange)
DefaultParameterSchema(ParameterSchema schema)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
fromString(String str)
Creates an Object from the String representation.List
getConstrainingList()
Gets the list of values that constrain this parameter.SteppedRange
getConstrainingRange()
Gets the numeric range of values that constrain this parameter.String
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)StringConverter
getConverter()
Gets the StringConverter if any.Object
getDefaultValue()
Gets the default value of the parameter.String
getName()
Gets the name of the parameter that this is the schema for.Class
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.String
toString(Object obj)
Converts the object into a String representation.boolean
validate(Object obj)
Validates the specified object against the type and optional constraint info for the parameter name.
-
-
-
Constructor Detail
-
DefaultParameterSchema
public DefaultParameterSchema(ParameterSchema schema)
-
DefaultParameterSchema
public DefaultParameterSchema(String name, Class type, Object defValue, List possibleValues)
-
DefaultParameterSchema
public DefaultParameterSchema(String name, Class type, Object defValue, SteppedRange constrainingRange)
-
-
Method Detail
-
getConverter
public StringConverter getConverter()
Gets the StringConverter if any.- Specified by:
getConverter
in interfaceParameterSchema
- Returns:
- the StringConverter
-
setConvertor
public void setConvertor(StringConverter converter)
Sets the converter for this schema.- Parameters:
converter
- the converter
-
getName
public String 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
public Class getType()
Gets the type of the parameter.- Specified by:
getType
in interfaceParameterSchema
- Returns:
- the type of the parameter.
-
getDefaultValue
public Object getDefaultValue()
Gets the default value of the parameter.- Specified by:
getDefaultValue
in interfaceParameterSchema
- Returns:
- the default value of the parameter.
-
setDefaultValue
public void setDefaultValue(Object obj)
Sets the default value of this parameter.- Specified by:
setDefaultValue
in interfaceParameterSchema
- Parameters:
obj
- the new default value
-
setConstrainingList
public void setConstrainingList(List list)
Sets the constraining list.- Parameters:
list
- the constraining list
-
setConstrainingRange
public void setConstrainingRange(SteppedRange range)
Sets the constraining range.- Parameters:
range
- the constraining range.
-
getConstrainingRange
public SteppedRange 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
public List 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
public String 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
public boolean validate(Object obj)
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
public String toString(Object obj)
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
public Object fromString(String str)
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
-
-