JCommanderParameterResolver implements ParameterResolver { @Override public boolean supports(MethodParameter parameter) { AtomicBoolean isSupported = new AtomicBoolean(false); Class<?> parameterType = parameter.getParameterType(); if (isLegalReflectiveAccess(parameterType)) { ReflectionUtils.doWithFields(parameterType, field -> { if (isLegalReflectiveAccess(field.getType())) { ReflectionUtils.makeAccessible(field); boolean hasAnnotation = Arrays.stream(field.getAnnotations()) .map(Annotation::annotationType) .anyMatch(JCOMMANDER_ANNOTATIONS::contains); isSupported.compareAndSet(false, hasAnnotation); } }); ReflectionUtils.doWithMethods(parameterType, method -> { if (isLegalReflectiveAccess(method.getDeclaringClass())) { ReflectionUtils.makeAccessible(method); boolean hasAnnotation = Arrays.stream(method.getAnnotations()) .map(Annotation::annotationType) .anyMatch(Parameter.class::equals); isSupported.compareAndSet(false, hasAnnotation); } }); } return isSupported.get(); }  @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 testSupportsJCommanderPojos() throws Exception { assertThat(resolver.supports(Utils.createMethodParameter(COMMAND_METHOD, 0))).isEqualTo(true); }
@Test public void testDoesNotSupportsNonJCommanderPojos() throws Exception { Method method = ReflectionUtils.findMethod(MyLordCommands.class, "apocalypse", String.class); assertThat(resolver.supports(Utils.createMethodParameter(method, 0))).isFalse(); }