args4j icon indicating copy to clipboard operation
args4j copied to clipboard

DelimitedOptionHandler<T> cannot be used with String

Open TreeRex opened this issue 11 years ago • 1 comments

You cannot create DelimitedOptionHandler<String> because the individualOptionHandler must derive from OneArgumentOptionHandler which StringOptionHandler does not.

TreeRex avatar Sep 13 '13 00:09 TreeRex

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()
    }
}

topr avatar Jun 12 '15 16:06 topr