final Map<String, Object> methods = new TreeMap<String, Object>();
try {
if (c == null) {
return methods;
}
final AnnotatedClass annotatedClass = AnnotationUtil.get(c
.getClass());
for (final AnnotatedMethod method : annotatedClass.getMethods()) {
if (isAvailable(method, null, requestParams, null)) {
// format as JSON
final List<Object> descParams = new ArrayList<Object>();
for (final AnnotatedParam param : method.getParams()) {
if (getRequestAnnotation(param, requestParams) == null) {
final String name = getName(param);
final Map<String, Object> paramData = new HashMap<String, Object>();
paramData.put("name", name);
paramData.put("type",
typeToString(param.getGenericType()));
paramData.put("required", isRequired(param));
descParams.add(paramData);
}
}
final Map<String, Object> result = new HashMap<String, Object>();
result.put("type",
typeToString(method.getGenericReturnType()));
final Map<String, Object> desc = new HashMap<String, Object>();
final String methodName = namespace.equals("") ? method
.getName() : namespace + "." + method.getName();
desc.put("method", methodName);
desc.put("params", descParams);
desc.put("result", result);
methods.put(methodName, desc);
}
}
for (final AnnotatedMethod method : annotatedClass
.getAnnotatedMethods(Namespace.class)) {
final String innerNamespace = method.getAnnotation(
Namespace.class).value();
methods.putAll(_describe(
method.getActualMethod().invoke(c, (Object[]) null),