snaq.util.jclap
Class EnumeratedOption<E>

java.lang.Object
  extended by snaq.util.jclap.Option<E>
      extended by 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

Constructor Summary
EnumeratedOption(java.lang.String shortName, java.lang.String longName, java.lang.String description, boolean mandatory, boolean allowMany, java.util.Collection<E> allowedValues)
          Creates a new EnumeratedOption instance.
EnumeratedOption(java.lang.String shortName, java.lang.String longName, java.lang.String description, int minCount, int maxCount, java.util.Collection<E> allowedValues)
          Creates a new EnumeratedOption instance.
 
Method Summary
 java.util.Collection<E> getAllowedValues()
          Returns an unmodifiable collection of the values that can be assigned to this option.
 java.lang.String getAllowedValuesString()
           
 java.lang.String getAllowedValuesString(java.lang.String fix, java.lang.String separator)
          Returns a string denoting the values that can be assigned to this option.
 java.lang.String getAllowedValuesString(java.lang.String prefix, java.lang.String suffix, java.lang.String separator)
          Returns a string denoting the values that can be assigned to this option.
 boolean isValueValid(E value)
           
 java.lang.String toString()
           
 
Methods inherited from class snaq.util.jclap.Option
equals, getDescription, getLongName, getMaxCount, getMinCount, getShortName, getType, getValues, hashCode, isAllowMany, isHidden, isMandatory, requiresValue, setHidden, setMinMaxCounts
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EnumeratedOption

public EnumeratedOption(java.lang.String shortName,
                        java.lang.String longName,
                        java.lang.String description,
                        int minCount,
                        int maxCount,
                        java.util.Collection<E> allowedValues)
Creates a new EnumeratedOption instance.

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 option
maxCount - maximum number of occurrences required for this option
allowedValues - collection of possible values this option can take

EnumeratedOption

public EnumeratedOption(java.lang.String shortName,
                        java.lang.String longName,
                        java.lang.String description,
                        boolean mandatory,
                        boolean allowMany,
                        java.util.Collection<E> allowedValues)
Creates a new EnumeratedOption instance.

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 specified
allowMany - 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 java.util.Collection<E> getAllowedValues()
Returns an unmodifiable collection of the values that can be assigned to this option.


getAllowedValuesString

public java.lang.String getAllowedValuesString(java.lang.String prefix,
                                               java.lang.String suffix,
                                               java.lang.String separator)
Returns a string denoting the values that can be assigned to this option.

Parameters:
prefix - prefix string for each allowed value
suffix - suffix string for each allowed value
separator - string to use for delimiting individual values
Returns:
A string denoting the values that can be assigned to this option.

getAllowedValuesString

public java.lang.String getAllowedValuesString(java.lang.String fix,
                                               java.lang.String separator)
Returns a string denoting the values that can be assigned to this option.

Parameters:
fix - prefix/suffix string for each allowed value (e.g. ")
separator - string to use for delimiting individual values
Returns:
A string denoting the values that can be assigned to this option.

getAllowedValuesString

public java.lang.String getAllowedValuesString()
Returns:
The default version of the string denoting the values that can be assigned to this option.

toString

public java.lang.String toString()
Overrides:
toString in class Option<E>