jcommander icon indicating copy to clipboard operation
jcommander copied to clipboard

@SubParameter Problems

Open antonio-rodriges opened this issue 5 years ago • 1 comments

There are at least 2 problems with @SubParameter

  1. It can set only public fields of a class
  2. It does not convert data types

Example code:

public class TuneOptions {
    @Parameter(names = "--tune", arity = 4, required = true)
    private TuneVariable tuneVariable;

     public static class TuneVariable {
        @SubParameter(order = 0)
        public String variableName;

        @SubParameter(order = 1)
        public double min;

        @SubParameter(order = 2)
        public double max;

        @SubParameter(order = 3)
        public double step;
  }
}

In the above code:

  1. variableName, min, max, step have to be public (otherwise there is an exception) which is not good and is different from usual jCommander behavior
  2. Parameters like --tune L 0 1 0.01 yield exception as 0 is treated as string and is not converted to double

antonio-rodriges avatar May 31 '20 11:05 antonio-rodriges

I'd like to work on this

fsd654qyl avatar Apr 25 '21 12:04 fsd654qyl