|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters.Parameter<Enum<E>,E> de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters.EnumParameter<E>
E
- Enum typepublic class EnumParameter<E extends Enum<E>>
Parameter class for a parameter specifying an enum type.
Usage:
// Enum declaration. enum MyEnum { VALUE1, VALUE2 }; // Parameter value holder. MyEnum myEnumParameter; // ... // Parameterization. EnumParameter<MyEnum> param = new EnumParameter<MyEnum>(ENUM_PROPERTY_ID, MyEnum.class); // OR EnumParameter<MyEnum> param = new EnumParameter<MyEnum>(ENUM_PROPERTY_ID, MyEnum.class, MyEnum.VALUE1); // OR EnumParameter<MyEnum> param = new EnumParameter<MyEnum>(ENUM_PROPERTY_ID, MyEnum.class, true); if(config.grab(param)) { myEnumParameter = param.getValue(); }
Field Summary | |
---|---|
protected Class<E> |
enumClass
Reference to the actual enum type, for T.valueOf(). |
Fields inherited from class de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters.Parameter |
---|
constraints, defaultValue, givenValue, optionalParameter, optionid, shortDescription |
Constructor Summary | |
---|---|
EnumParameter(OptionID optionID,
Class<E> enumClass)
Constructs an enum parameter with the given optionID, constraints and default value. |
|
EnumParameter(OptionID optionID,
Class<E> enumClass,
boolean optional)
Constructs an enum parameter with the given optionID, constraints and default value. |
|
EnumParameter(OptionID optionID,
Class<E> enumClass,
E defaultValue)
Constructs an enum parameter with the given optionID, constraints and default value. |
Method Summary | |
---|---|
Collection<String> |
getPossibleValues()
Get a list of possible values for this enum parameter. |
String |
getSyntax()
Returns a string representation of the parameter's type (e.g. an IntParameter
should return <int> ). |
String |
getValueAsString()
Get the value as string. |
private String |
joinEnumNames(String separator)
Utility method for merging possible values into a string for informational messages. |
protected E |
parseValue(Object obj)
Parse a given value into the destination type. |
Methods inherited from class de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters.Parameter |
---|
addConstraint, getDefaultValue, getDefaultValueAsString, getFullDescription, getGivenValue, getName, getOptionID, getShortDescription, getValue, getValuesDescription, hasDefaultValue, hasValuesDescription, isDefined, isOptional, isValid, setDefaultValue, setOptional, setShortDescription, setValue, setValueInternal, tookDefaultValue, tryDefaultValue, useDefaultValue, validate |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Class<E extends Enum<E>> enumClass
Constructor Detail |
---|
public EnumParameter(OptionID optionID, Class<E> enumClass, E defaultValue)
optionID
- the unique id of the parameterdefaultValue
- the default value of the parameterpublic EnumParameter(OptionID optionID, Class<E> enumClass, boolean optional)
optionID
- the unique id of the parameteroptional
- Flag to signal an optional parameter.public EnumParameter(OptionID optionID, Class<E> enumClass)
optionID
- the unique id of the parameterMethod Detail |
---|
public String getSyntax()
Parameter
IntParameter
should return <int>
).
getSyntax
in class Parameter<Enum<E extends Enum<E>>,E extends Enum<E>>
protected E parseValue(Object obj) throws ParameterException
Parameter
parseValue
in class Parameter<Enum<E extends Enum<E>>,E extends Enum<E>>
obj
- Object to parse (may be a string representation!)
ParameterException
- when the object cannot be parsed.public String getValueAsString()
Parameter
null
getValueAsString
in class Parameter<Enum<E extends Enum<E>>,E extends Enum<E>>
public Collection<String> getPossibleValues()
private String joinEnumNames(String separator)
separator
- char sequence to use as a separator for enum values.
{VAL1}{separator}{VAL2}{separator}...
|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |