Class EnumArgumentType<T extends java.lang.Enum<T>>
- java.lang.Object
-
- net.sourceforge.argparse4j.impl.type.EnumArgumentType<T>
-
- Type Parameters:
T- Type of enum
- All Implemented Interfaces:
ArgumentType<T>
@Deprecated public class EnumArgumentType<T extends java.lang.Enum<T>> extends java.lang.Object implements ArgumentType<T>
Deprecated.UseReflectArgumentTypeinstead.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. Inconvert(ArgumentParser, Argument, String), String value will be converted to one of them. If it cannot be converted,convert(ArgumentParser, Argument, String)will throwArgumentParserException. This means it already act like aArgument.choices(Object...).
-
-
Constructor Summary
Constructors Constructor Description EnumArgumentType(java.lang.Class<T> type)Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Tconvert(ArgumentParser parser, Argument arg, java.lang.String value)Deprecated.Convertsvalueto appropriate type.
-
-
-
Constructor Detail
-
EnumArgumentType
public EnumArgumentType(java.lang.Class<T> type)
Deprecated.
-
-
Method Detail
-
convert
public T convert(ArgumentParser parser, Argument arg, java.lang.String value) throws ArgumentParserException
Deprecated.Description copied from interface:ArgumentTypeConverts
valueto appropriate type.If the objects derived from
RuntimeExceptionare thrown in conversion because of invalid input from command line, subclass must catch these exceptions and wrap them inArgumentParserExceptionand give simple error message to explain what happened briefly.- Specified by:
convertin interfaceArgumentType<T extends java.lang.Enum<T>>- Parameters:
parser- The parser.arg- The argument this type attached to.value- The attribute value.- Returns:
- Converted object.
- Throws:
ArgumentParserException- If conversion fails.
-
-