Option optionAnn = null; Boolean required = null; Description description = new Description(ab); Annotation info = null; for (Annotation parameterAnnotation : ab) { description = new Description(description, new Description(a));
descriptor = new CommandDescriptor<Object>(name, new Description()) { @Override public CommandDescriptor<Object> getOwner() {
} else { Map<String, MethodDescriptor<T>> methodMap = new LinkedHashMap<String, MethodDescriptor<T>>(); ClassDescriptor<T> classDescriptor = new ClassDescriptor<T>(type, commandName, methodMap, new Description(type)); for (Method method : methods) { String methodName;
private <T> MethodDescriptor<T> create(ClassDescriptor<T> classDescriptor, String name, Method method) throws IntrospectionException { Description info = new Description(method); MethodDescriptor<T> methodDescriptor = new MethodDescriptor<T>( classDescriptor, method, name, info); Type[] parameterTypes = method.getGenericParameterTypes(); Annotation[][] parameterAnnotationMatrix = method.getParameterAnnotations(); for (int i = 0;i < parameterAnnotationMatrix.length;i++) { Annotation[] parameterAnnotations = parameterAnnotationMatrix[i]; Type parameterType = parameterTypes[i]; Tuple tuple = get(parameterAnnotations); MethodArgumentBinding binding = new MethodArgumentBinding(i); ParameterDescriptor parameter = create( binding, parameterType, tuple.argumentAnn, tuple.optionAnn, tuple.required, tuple.descriptionAnn, tuple.ann); if (parameter != null) { methodDescriptor.addParameter(parameter); } else { log.log(Level.FINE, "Method argument with index " + i + " of method " + method + " is not annotated"); } } return methodDescriptor; }
public void testNoDescription() throws Exception { class A { } CommandDescriptor<Instance<A>> c = CommandFactory.DEFAULT.create(A.class); assertEquals("", c.getUsage()); assertEquals(new Description(), c.getDescription()); }
public void testParameterMetaDescription2() throws Exception { class A { @Command void m(@Bar String s) {} } CommandDescriptor<Instance<A>> c = CommandFactory.DEFAULT.create(A.class); CommandDescriptor<Instance<A>> m = c.getSubordinate("m"); OptionDescriptor a = m.getOption("-a"); assertEquals("", a.getUsage()); assertEquals(new Description(), a.getDescription()); }
Option optionAnn = null; Boolean required = null; Description description = new Description(ab); Annotation info = null; for (Annotation parameterAnnotation : ab) { description = new Description(description, new Description(a));
Option optionAnn = null; Boolean required = null; Description description = new Description(ab); Annotation info = null; for (Annotation parameterAnnotation : ab) { description = new Description(description, new Description(a));
public <T> CommandDescriptorImpl<T> create(Class<T> type) throws IntrospectionException { // Map<String, MethodDescriptor<T>> methodMap = new LinkedHashMap<String, MethodDescriptor<T>>(); ClassDescriptor<T> descriptor = new ClassDescriptor<T>(type, methodMap, new Description(type)); for (MethodDescriptor<T> method : commands(descriptor, type)) { methodMap.put(method.getName(), method); } // for (ParameterDescriptor parameter : parameters(type)) { descriptor.addParameter(parameter); } // return descriptor; }
descriptor = new CommandDescriptor<Object>(name, new Description()) { @Override public CommandDescriptor<Object> getOwner() {
descriptor = new CommandDescriptor<Object>(name, new Description()) { @Override public CommandDescriptor<Object> getOwner() {
Description info = new Description(m); MethodDescriptor<T> descriptor = new MethodDescriptor<T>( owner,
} else { Map<String, MethodDescriptor<T>> methodMap = new LinkedHashMap<String, MethodDescriptor<T>>(); ClassDescriptor<T> classDescriptor = new ClassDescriptor<T>(type, commandName, methodMap, new Description(type)); for (Method method : methods) { String methodName;
private <T> MethodDescriptor<T> create(ClassDescriptor<T> classDescriptor, String name, Method method) throws IntrospectionException { Description info = new Description(method); MethodDescriptor<T> methodDescriptor = new MethodDescriptor<T>( classDescriptor, method, name, info); Type[] parameterTypes = method.getGenericParameterTypes(); Annotation[][] parameterAnnotationMatrix = method.getParameterAnnotations(); for (int i = 0;i < parameterAnnotationMatrix.length;i++) { Annotation[] parameterAnnotations = parameterAnnotationMatrix[i]; Type parameterType = parameterTypes[i]; Tuple tuple = get(parameterAnnotations); MethodArgumentBinding binding = new MethodArgumentBinding(i); ParameterDescriptor parameter = create( binding, parameterType, tuple.argumentAnn, tuple.optionAnn, tuple.required, tuple.descriptionAnn, tuple.ann); if (parameter != null) { methodDescriptor.addParameter(parameter); } else { log.log(Level.FINE, "Method argument with index " + i + " of method " + method + " is not annotated"); } } return methodDescriptor; }