Interface Parameter<T>
-
- Type Parameters:
T
- the type of a possible value (i.e., the type of the option)
- All Known Implementing Classes:
AbstractParameter
,ClassListParameter
,ClassParameter
,DoubleArrayListParameter
,DoubleListParameter
,DoubleParameter
,DynamicParameters.RemainingOptions
,EnumParameter
,FileListParameter
,FileParameter
,Flag
,IntGeneratorParameter
,IntListParameter
,IntParameter
,ListParameter
,LongParameter
,NumberParameter
,ObjectListParameter
,ObjectParameter
,PatternParameter
,RandomParameter
,StringParameter
public interface Parameter<T>
Interface for the parameter of a class.A parameter is defined as an option having a specific value.
See the
elki.utilities.optionhandling
package for documentation!- Since:
- 0.1
- Author:
- Steffi Wanka, Erich Schubert
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Parameter<T>
addConstraint(ParameterConstraint<? super T> constraint)
Add an additional constraint.java.lang.StringBuilder
describeValues(java.lang.StringBuilder description)
Describe the valid values.java.util.List<ParameterConstraint<? super T>>
getConstraints()
Get the parameter constraints.T
getDefaultValue()
Returns the default value of the parameter.java.lang.String
getDefaultValueAsString()
Get the default value as string.OptionID
getOptionID()
Return the OptionID of this option.java.lang.String
getSyntax()
Returns a string representation of the parameter's type (e.g., anIntParameter
should return<int>
).T
getValue()
Returns the value of the option.java.lang.String
getValueAsString()
Get the value as string.boolean
hasDefaultValue()
Checks if this parameter has a default value.boolean
isDefined()
Returns true if the value of the option is defined, false otherwise.boolean
isOptional()
Checks if this parameter is an optional parameter.boolean
isValid(java.lang.Object obj)
Checks if the given argument is valid for this option.Parameter<T>
setDefaultValue(T defaultValue)
Sets the default value of this parameter.Parameter<T>
setOptional(boolean opt)
Specifies if this parameter is an optional parameter.void
setValue(java.lang.Object obj)
Sets the value of the option.boolean
tookDefaultValue()
Checks if the default value of this parameter was taken as the actual parameter value.boolean
tryDefaultValue()
Handle default values for a parameter.
-
-
-
Method Detail
-
setDefaultValue
Parameter<T> setDefaultValue(T defaultValue)
Sets the default value of this parameter.- Parameters:
defaultValue
- default value of this parameter- Returns:
- the parameter itself, for chaining
-
hasDefaultValue
boolean hasDefaultValue()
Checks if this parameter has a default value.- Returns:
- true, if this parameter has a default value, false otherwise
-
tryDefaultValue
boolean tryDefaultValue() throws UnspecifiedParameterException
Handle default values for a parameter.- Returns:
- Return code:
true
if it has a default value,false
if it is optional without a default value. Exception if it is a required parameter! - Throws:
UnspecifiedParameterException
- If the parameter requires a value
-
setOptional
Parameter<T> setOptional(boolean opt)
Specifies if this parameter is an optional parameter.- Parameters:
opt
- true if this parameter is optional, false otherwise- Returns:
- the parameter itself, for chaining
-
isOptional
boolean isOptional()
Checks if this parameter is an optional parameter.- Returns:
- true if this parameter is optional, false otherwise
-
tookDefaultValue
boolean tookDefaultValue()
Checks if the default value of this parameter was taken as the actual parameter value.- Returns:
- true, if the default value was taken as actual parameter value, false otherwise
-
isDefined
boolean isDefined()
Returns true if the value of the option is defined, false otherwise.- Returns:
- true if the value of the option is defined, false otherwise.
-
getDefaultValue
T getDefaultValue()
Returns the default value of the parameter.If the parameter has no default value, the method returns null.
- Returns:
- the default value of the parameter, null if the parameter has no default value.
-
getOptionID
OptionID getOptionID()
Return the OptionID of this option.- Returns:
- Option ID
-
setValue
void setValue(java.lang.Object obj) throws ParameterException
Sets the value of the option.- Parameters:
obj
- the option's value to be set- Throws:
ParameterException
- if the given value is not a valid value for this option.
-
getValue
T getValue()
Returns the value of the option.You should use either
Parameterization.grab(elki.utilities.optionhandling.parameters.Parameter<?>)
orisDefined()
to test if getValue() will return a well-defined value.- Returns:
- the option's value.
-
isValid
boolean isValid(java.lang.Object obj) throws ParameterException
Checks if the given argument is valid for this option.- Parameters:
obj
- option value to be checked- Returns:
- true, if the given value is valid for this option
- Throws:
ParameterException
- if the given value is not a valid value for this option.
-
getSyntax
java.lang.String getSyntax()
Returns a string representation of the parameter's type (e.g., anIntParameter
should return<int>
).- Returns:
- a string representation of the parameter's type
-
getValueAsString
java.lang.String getValueAsString()
Get the value as string. May returnnull
- Returns:
- Value as string
-
getDefaultValueAsString
java.lang.String getDefaultValueAsString()
Get the default value as string.- Returns:
- default value
-
describeValues
java.lang.StringBuilder describeValues(java.lang.StringBuilder description)
Describe the valid values.- Parameters:
description
- Buffer to append to- Returns:
- Buffer
-
addConstraint
Parameter<T> addConstraint(ParameterConstraint<? super T> constraint)
Add an additional constraint.- Parameters:
constraint
- Constraint to add.- Returns:
- the parameter itself, for chaining
-
getConstraints
java.util.List<ParameterConstraint<? super T>> getConstraints()
Get the parameter constraints.- Returns:
- Parameter constraints
-
-