Class EnumArgumentType<T extends Enum<T>>
- Type Parameters:
T
- Type of enum
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconvert
(ArgumentParser parser, Argument arg, String value) Deprecated.Convertsvalue
to appropriate type.
-
Constructor Details
-
EnumArgumentType
Deprecated.
-
-
Method Details
-
convert
Deprecated.Description copied from interface: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 inArgumentParserException
and give simple error message to explain what happened briefly.- Specified by:
convert
in interfaceArgumentType<T extends Enum<T>>
- Parameters:
parser
- The aprser.arg
- The argument this type attached to.value
- The attribute value.- Returns:
- Converted object.
- Throws:
ArgumentParserException
- If conversion fails.
-
ReflectArgumentType
instead.