E
- Enum typepublic class EnumParameter<E extends Enum<E>> extends AbstractParameter<EnumParameter<E>,E>
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(); }
Modifier and Type | Field and Description |
---|---|
protected Class<E> |
enumClass
Reference to the actual enum type, for T.valueOf().
|
constraints, defaultValue, givenValue, optionalParameter, optionid, shortDescription
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
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.
|
String |
getValuesDescription()
Return a string explaining valid values.
|
boolean |
hasValuesDescription()
This class sometimes provides a list of value descriptions.
|
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.
|
addConstraint, getDefaultValue, getDefaultValueAsString, getFullDescription, getGivenValue, getName, getOptionID, getShortDescription, getValue, hasDefaultValue, isDefined, isOptional, isValid, setDefaultValue, setOptional, setShortDescription, setValue, setValueInternal, tookDefaultValue, tryDefaultValue, useDefaultValue, validate
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 String getSyntax()
Parameter
IntParameter
should return <int>
).protected E parseValue(Object obj) throws ParameterException
AbstractParameter
parseValue
in class AbstractParameter<EnumParameter<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 interface Parameter<E extends Enum<E>>
getValueAsString
in class AbstractParameter<EnumParameter<E extends Enum<E>>,E extends Enum<E>>
public boolean hasValuesDescription()
hasValuesDescription
in interface Parameter<E extends Enum<E>>
hasValuesDescription
in class AbstractParameter<EnumParameter<E extends Enum<E>>,E extends Enum<E>>
AbstractParameter.hasValuesDescription()
public String getValuesDescription()
Parameter
getValuesDescription
in interface Parameter<E extends Enum<E>>
getValuesDescription
in class AbstractParameter<EnumParameter<E extends Enum<E>>,E extends Enum<E>>
public Collection<String> getPossibleValues()
Copyright © 2015 ELKI Development Team, Lehr- und Forschungseinheit für Datenbanksysteme, Ludwig-Maximilians-Universität München. License information.