public class OptionDescription extends Object
Add a class reference to OptionDescription.parsers in order to instruct OptionParser how to interpret option values into new types. For example, OptionParser could be taught to understand BigInteger thus:
OptionDescription.parsers.put(BigInteger.class, new ValueParser() { public Object parse(OptionDescription desc, Class<?> type, String value) throws InvalidOptionValue { return new BigInteger(value); } });
Note that this occurs during scanning, so the new ValueParser must be inserted before the OptionParser is created.
OptionParser
Modifier and Type | Field and Description |
---|---|
Set<String> |
alternatives
If now null, the values allowed for this option; currently used for enums
|
Object |
defaultValue
default value of this option at time of scanning
|
String |
documentation
documentation string, as picked up from @Option
|
Field |
field
The field object representing the referenced class member
|
String |
longOptionName
Full name of the option
|
static Map<Class<?>,ValueParser> |
parsers
Map of known ValueParsers.
|
String |
shortOptionName
Short (one-letter) version of option, or null if none.
|
ValueParser |
valueParser |
Constructor and Description |
---|
OptionDescription(Field field) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
void |
extractDefaultValue(Object options) |
Class<?> |
getType() |
Object |
interpretValue(String value) |
public static final Map<Class<?>,ValueParser> parsers
public String longOptionName
public String shortOptionName
public Object defaultValue
public String documentation
public Set<String> alternatives
public Field field
public ValueParser valueParser
public OptionDescription(Field field)
public void extractDefaultValue(Object options)
public Object interpretValue(String value) throws InvalidOptionValue
InvalidOptionValue
public Class<?> getType()
Copyright © 2013. All Rights Reserved.