JCommanderParameterResolver implements ParameterResolver { @Override public Stream<ParameterDescription> describe(MethodParameter parameter) { JCommander jCommander = createJCommander(parameter); Stream<com.beust.jcommander.ParameterDescription> jCommanderDescriptions = streamAllJCommanderDescriptions( jCommander); BeanDescriptor constraintsForClass = validator.getConstraintsForClass(parameter.getParameterType()); return jCommanderDescriptions .map(j -> new ParameterDescription(parameter, unCamelify(j.getParameterized().getType().getSimpleName())) .keys(Arrays.asList(j.getParameter().names())) .help(j.getDescription()) .mandatoryKey(!j.equals(jCommander.getMainParameter())) .defaultValue(j.getDefault() == null ? "" : String.valueOf(j.getDefault())) .elementDescriptor( constraintsForClass.getConstraintsForProperty(j.getParameterized().getName()))); }  @Autowired(required = false) void setValidatorFactory(ValidatorFactory validatorFactory); @Override boolean supports(MethodParameter parameter); @Override ValueResult resolve(MethodParameter methodParameter, List<String> words); @Override Stream<ParameterDescription> describe(MethodParameter parameter); @Override List<CompletionProposal> complete(MethodParameter parameter, CompletionContext context);  }
@Test public void testDescribe() { MethodParameter methodParameter = Utils.createMethodParameter(COMMAND_METHOD, 0); Stream<ParameterDescription> desciptions = resolver.describe(methodParameter); ParameterDescription name = new ParameterDescription(methodParameter, "string") .keys(Arrays.asList("--name", "-n")) .help("what's in a name?") .defaultValue(""); ParameterDescription level = new ParameterDescription(methodParameter, "int") .keys(singletonList("-level")) .defaultValue("3"); ParameterDescription rest = new ParameterDescription(methodParameter, "list") .defaultValue("[]") .mandatoryKey(false) .help("rest"); assertThat(desciptions).contains(name, level, rest); }