Package snaq.util.jclap
Class EnumeratedStringOption
public final class EnumeratedStringOption extends EnumeratedOption<String>
Implementation of an
Option with value restricted to a
specified enumeration of type String.- Author:
- Giles Winstanley
-
Field Summary
-
Constructor Summary
Constructors Constructor Description EnumeratedStringOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany, Collection<String> allowedValues, boolean ignoreCase)Creates a newEnumeratedStringOptioninstance.EnumeratedStringOption(String shortName, String longName, String description, int minCount, int maxCount, Collection<String> allowedValues, boolean ignoreCase)Creates a newEnumeratedStringOptioninstance. -
Method Summary
Modifier and Type Method Description StringgetAllowedValuesString()Returns the default version of the string denoting the values that can be assigned to this option.Class<String>getType()Returns the class type of value this option can take.booleanisValueValid(String value, Locale locale)protected StringparseValue(String arg, Locale locale)Parses the argument string for an option value, optionally using the specified locale for reference (e.g.Methods inherited from class snaq.util.jclap.EnumeratedOption
getAllowedValues, getAllowedValuesString, toStringMethods inherited from class snaq.util.jclap.Option
addValue, equals, getDescription, getLongName, getMaxCount, getMinCount, getShortName, getValues, hashCode, isAllowMany, isHidden, isMandatory, requiresValue, setHidden, setMinMaxCounts
-
Constructor Details
-
EnumeratedStringOption
public EnumeratedStringOption(String shortName, String longName, String description, int minCount, int maxCount, Collection<String> allowedValues, boolean ignoreCase)Creates a newEnumeratedStringOptioninstance.- Parameters:
shortName- short name of the option (e.g. -t)longName- long name of the option (e.g. --type)description- helpful description of the option (printed for usage message)minCount- minimum number of occurrences required for this optionmaxCount- maximum number of occurrences required for this optionallowedValues- collection of possible values this option can takeignoreCase- whether to ignore the case in string evaluations
-
EnumeratedStringOption
public EnumeratedStringOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany, Collection<String> allowedValues, boolean ignoreCase)Creates a newEnumeratedStringOptioninstance.- Parameters:
shortName- short name of the option (e.g. -t)longName- long name of the option (e.g. --type)description- helpful description of the option (printed for usage message)mandatory- whether this option must be specifiedallowMany- whether this option can take more than one value (i.e. be specified more than once)allowedValues- collection of possible values this option can takeignoreCase- whether to ignore the case in string evaluations
-
-
Method Details
-
isValueValid
- Overrides:
isValueValidin classEnumeratedOption<String>- Parameters:
value- value to check for validitylocale- Locale to use for i18n (if needed)- Returns:
- Whether the specified value is valid.
-
parseValue
Parses the argument string for an option value, optionally using the specified locale for reference (e.g. for date parsing).- Specified by:
parseValuein classOption<String>- Parameters:
arg- string argument from which a value is to be parsedlocale- locale as specified when initializing theCLAParserinstance- Returns:
- Value of the parsed argument string
- Throws:
OptionException- if a problem occurs while parsing the argument string
-
getType
Returns the class type of value this option can take. -
getAllowedValuesString
Returns the default version of the string denoting the values that can be assigned to this option.- Overrides:
getAllowedValuesStringin classEnumeratedOption<String>- Returns:
- comma-separated quoted string of allowed values
-