Module net.sourceforge.argparse4j
Class ConstructorArgumentType<T>
- java.lang.Object
-
- net.sourceforge.argparse4j.impl.type.ConstructorArgumentType<T>
-
- All Implemented Interfaces:
ArgumentType<T>
@Deprecated public class ConstructorArgumentType<T> extends java.lang.Object implements ArgumentType<T>
Deprecated.UseReflectArgumentType
instead.This implementation converts String value into given type using given type's constructor.
The constructor must have 1 String argument. If error occurred inside the constructor,
ArgumentParserException
will be thrown. If error occurred in other locations, subclass ofRuntimeException
will be thrown.
-
-
Constructor Summary
Constructors Constructor Description ConstructorArgumentType(java.lang.Class<T> type)
Deprecated.CreatesConstructorArgumentType
object with giventype
.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description T
convert(ArgumentParser parser, Argument arg, java.lang.String value)
Deprecated.Convertsvalue
to appropriate type.private void
handleInstantiationError(java.lang.Exception e)
Deprecated.
-
-
-
Field Detail
-
type_
private final java.lang.Class<T> type_
Deprecated.
-
-
Constructor Detail
-
ConstructorArgumentType
public ConstructorArgumentType(java.lang.Class<T> type)
Deprecated.Creates
ConstructorArgumentType
object with giventype
.The constructor of
type
must have 1 String argument.- Parameters:
type
- The type String value should be converted to.
-
-
Method Detail
-
convert
public T convert(ArgumentParser parser, Argument arg, java.lang.String value) throws ArgumentParserException
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>
- Parameters:
parser
- The parser.arg
- The argument this type attached to.value
- The attribute value.- Returns:
- Converted object.
- Throws:
ArgumentParserException
- If conversion fails.
-
handleInstantiationError
private void handleInstantiationError(java.lang.Exception e)
Deprecated.
-
-