T - Type of enumpublic class CaseInsensitiveEnumArgumentType<T extends Enum<T>> extends Object implements ArgumentType<T>, MetavarInference
ArgumentType subclass for enum type with case-insensitive match.
If enum type is passed to Argument.type(Class), string comparison is
performed in case-sensitive (this is default for all other type conversions).
Usually in convention, enum name is all upper case letters, some times you
want to do case-insensitive match for convenience. This class does that job.
| Constructor and Description |
|---|
CaseInsensitiveEnumArgumentType(Class<T> type) |
| Modifier and Type | Method and Description |
|---|---|
T |
convert(ArgumentParser parser,
Argument arg,
String value)
Converts
value to appropriate type. |
String[] |
inferMetavar()
Returns inferred array of metavar strings.
|
public T convert(ArgumentParser parser, Argument arg, String value) throws ArgumentParserException
ArgumentType
Converts value to appropriate type.
If the objects derived from RuntimeException are thrown in
conversion because of invalid input from command line, subclass must
catch these exceptions and wrap them in ArgumentParserException
and give simple error message to explain what happened briefly.
convert in interface ArgumentType<T extends Enum<T>>parser - The aprser.arg - The argument this type attached to.value - The attribute value.ArgumentParserException - If conversion fails.public String[] inferMetavar()
MetavarInferenceReturns inferred array of metavar strings.
The returned array is treated like when strings are given in
Argument.metavar(String...).
inferMetavar in interface MetavarInferenceCopyright © 2012–2015. All rights reserved.