Package snaq.util.jclap
Class EnumeratedOption<E>
java.lang.Object
snaq.util.jclap.Option<E>
snaq.util.jclap.EnumeratedOption<E>
- Type Parameters:
E- the return type of the option
- Direct Known Subclasses:
EnumeratedIntegerOption,EnumeratedStringOption
public abstract class EnumeratedOption<E> extends Option<E>
Implementation of an
Option with value restricted to an
enumeration of a specified return value type.- Author:
- Giles Winstanley
-
Field Summary
-
Constructor Summary
Constructors Constructor Description EnumeratedOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany, Collection<E> allowedValues)Creates a newEnumeratedOptioninstance.EnumeratedOption(String shortName, String longName, String description, int minCount, int maxCount, Collection<E> allowedValues)Creates a newEnumeratedOptioninstance. -
Method Summary
Modifier and Type Method Description Collection<E>getAllowedValues()Returns an unmodifiable collection of the values that can be assigned to this option.StringgetAllowedValuesString()StringgetAllowedValuesString(String prefix, String suffix, String separator)Returns a string denoting the values that can be assigned to this option.booleanisValueValid(E value, Locale locale)StringtoString()Methods inherited from class snaq.util.jclap.Option
addValue, equals, getDescription, getLongName, getMaxCount, getMinCount, getShortName, getType, getValues, hashCode, isAllowMany, isHidden, isMandatory, parseValue, requiresValue, setHidden, setMinMaxCounts
-
Constructor Details
-
EnumeratedOption
public EnumeratedOption(String shortName, String longName, String description, int minCount, int maxCount, Collection<E> allowedValues)Creates a newEnumeratedOptioninstance.- 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 take
-
EnumeratedOption
public EnumeratedOption(String shortName, String longName, String description, boolean mandatory, boolean allowMany, Collection<E> allowedValues)Creates a newEnumeratedOptioninstance.- 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 take
-
-
Method Details
-
isValueValid
- Parameters:
value- value to check for validitylocale- Locale to use for i18n (if needed)- Returns:
- Whether the specified value is valid.
-
getAllowedValues
Returns an unmodifiable collection of the values that can be assigned to this option.- Returns:
- collection of allowed option values
-
getAllowedValuesString
Returns a string denoting the values that can be assigned to this option.- Parameters:
prefix- prefix string for each allowed valuesuffix- suffix string for each allowed valueseparator- string to use for delimiting individual values- Returns:
- A string denoting the values that can be assigned to this option.
-
getAllowedValuesString
- Returns:
- The default version of the string denoting the values that can be assigned to this option.
-
toString
-