T
- Type of enumReflectArgumentType
instead.@Deprecated public class EnumArgumentType<T extends Enum<T>> extends Object implements ArgumentType<T>
ArgumentType subclass for enum type.
Since enum does not have a constructor with string argument, it cannot be
used with Argument.type(Class)
. Instead use this class to specify
enum type. The enums in its nature have limited number of members. In
convert(ArgumentParser, Argument, String)
, String value will be
converted to one of them. If it cannot be converted,
convert(ArgumentParser, Argument, String)
will throw
ArgumentParserException
. This means it already act like a
Argument.choices(Object...)
.
Constructor and Description |
---|
EnumArgumentType(Class<T> type)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
T |
convert(ArgumentParser parser,
Argument arg,
String value)
Deprecated.
Converts
value to appropriate type. |
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 parser.arg
- The argument this type attached to.value
- The attribute value.ArgumentParserException
- If conversion fails.Copyright © 2012–2017. All rights reserved.