args4j
args4j copied to clipboard
DelimitedOptionHandler<T> cannot be used with String
You cannot create DelimitedOptionHandler<String>
because the individualOptionHandler
must derive from OneArgumentOptionHandler
which StringOptionHandler
does not.
I came here to report the same.
Why StringOptionHandler
doesn't inherit from OneArgumentOptionHandler
?
It seems like a major inconsistency issue compared to all other 'simple' type option handlers.
I ended up reinventing the wheel:
class StringOptionHandler extends OneArgumentOptionHandler<String> {
StringOptionHandler(CmdLineParser parser, OptionDef option, Setter<? super String> setter) {
super(parser, option, setter)
}
@Override
protected String parse(String argument) throws NumberFormatException {
argument.trim()
}
}