- 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 anOptionwith value restricted to an enumeration of a specified return value type.- Author:
- Giles Winstanley
-
-
Field Summary
-
Fields inherited from class snaq.util.jclap.Option
BUNDLE, LOCALE, MAX_COUNT_LIMIT, MIN_COUNT_LIMIT
-
-
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
All Methods Instance Methods Concrete Methods 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)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 Detail
-
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 Detail
-
isValueValid
public boolean isValueValid(E value)
- Parameters:
value- value to check for validity- Returns:
- Whether the specified value is valid.
-
getAllowedValues
public Collection<E> getAllowedValues()
Returns an unmodifiable collection of the values that can be assigned to this option.- Returns:
- collection of allowed option values
-
getAllowedValuesString
public String getAllowedValuesString(String prefix, String suffix, String separator)
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
public String getAllowedValuesString()
- Returns:
- The default version of the string denoting the values that can be assigned to this option.
-
-