jcommander
jcommander copied to clipboard
Add support for adding classes, not only instances
Sometimes, when working with static fields, it would be most convenient to be able to pass a class (SomeClass.class) to JCommander instead of an instance. Sometimes, instances aren't even possible to make (for abstract classes, for example).
The following code expresses my wish:
public class Tada {
public static void main(String[] args) {
new JCommander(One.class, args);
}
}
class One {
@Parameter(names = "-somename", description = "Ba dum - tss!")
public static String someVariable;
}
There's no need to instantiate One and I don't really want to do it - it might have serious side-effects I need to avoid until the instance is really needed.