C
- option typeT
- parameter result typepublic abstract class AbstractChoiceParameter<T,C> extends Parameter<T>
Modifier | Constructor and Description |
---|---|
protected |
AbstractChoiceParameter(String name,
Class<T> paramClazz,
Class<C> optClazz,
C[] options)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addOption(C option)
Adds an option value to this parameter.
|
void |
addOption(C option,
String name)
Adds an option value to this parameter with a given name.
|
protected String |
choiceToString(C objVal)
Provides a string representation of a given typed value
for this parameter.
|
void |
clearOptions()
Clears the list of known options.
|
String |
getName(C option)
Converts an option value object to a string which is used to identify
it as a string value of this parameter.
|
C |
getOption(String name)
Returns the option value associated with a given string by this
parameter.
|
String[] |
getOptionNames()
Returns an array of the string values of options accepted by this
parameter.
|
C[] |
getOptions()
Returns an array of the option objects which may form the
values of this parameter.
|
Collection<C> |
getOptionValueList()
Returns a collection of the option objects which may form the
values of this parameter.
|
String |
stringifyOption(C option)
Determines how an option will be represented as a string value of
this parameter if no name has explicitly been supplied.
|
protected C |
stringToChoice(String sval)
Converts a supplied string to an option value for this parameter,
or throws a ParameterValueException if it is not suitable.
|
clearValue, getDescription, getName, getPosition, getPreferExplicit, getPrompt, getStringDefault, getUsage, getValueClass, isNullPermitted, objectToString, objectValue, setDescription, setDescription, setName, setNullPermitted, setPosition, setPreferExplicit, setPrompt, setStringDefault, setUsage, setValue, setValueFromObject, setValueFromString, stringToObject, stringValue, toArray, toString
protected AbstractChoiceParameter(String name, Class<T> paramClazz, Class<C> optClazz, C[] options)
name
- parameter nameparamClazz
- class of result type for this parameteroptClazz
- class of typed optionoptions
- initial list of typed options availablepublic void addOption(C option, String name)
option
- option objectname
- label for optionpublic void addOption(C option)
stringifyOption(C)
method.option
- option objectpublic void clearOptions()
public String[] getOptionNames()
public C[] getOptions()
public Collection<C> getOptionValueList()
public String getName(C option)
option
- option valuepublic String stringifyOption(C option)
String.valueOf(option)
,
but this may be overrridden.option
- option valuepublic C getOption(String name)
name
- name of option which has been addedprotected C stringToChoice(String sval) throws ParameterValueException
sval
- option nameParameterValueException
- if no such optionCopyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.