Skip to content

An IParametersValidator on an ParametersDelegate should not be lifted to the top-level object #575

@ekpdt

Description

@ekpdt

Take the following example:

  @Parameters(parametersValidators = MyValidator.class)
  static final class SubGroup {
    @Parameter(names = "--arg1")
    private boolean arg1;

    @Parameter(names = "--arg2")
    private String arg2;
  }

  static final class ArgsTop {
    @Parameter(names = "--argtop")
    private boolean argtop;

    @ParametersDelegate
    private SubGroup subGroup = new SubGroup();
  }

  public static void main(String[] args) {
    var args = new ArgsTop();
    JCommander.newBuilder().addObject(args).build();  // MyValidator::validate invoked reflectively here.
  }

When MyValidator::validate is invoked, it should only see entries for arg1 and arg2, not argtop.
This would make it much easier to implement generic mutex groups. I think it would also be more intuitive.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions