private static Map<String, Object> _describe(Object c,
RequestParams requestParams, String namespace) {
Map<String, Object> methods = new TreeMap<String, Object>();
try {
AnnotatedClass annotatedClass = AnnotationUtil.get(c.getClass());
for (AnnotatedMethod method : annotatedClass.getMethods()) {
if (isAvailable(method, null, requestParams, null)) {
// format as JSON
List<Object> descParams = new ArrayList<Object>();
for (AnnotatedParam param : method.getParams()) {
if (getRequestAnnotation(param, requestParams) == null) {
String name = getName(param);
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);
}
}
Map<String, Object> result = new HashMap<String, Object>();
result.put("type",
typeToString(method.getGenericReturnType()));
Map<String, Object> desc = new HashMap<String, Object>();
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 (AnnotatedMethod method : annotatedClass
.getAnnotatedMethods(Namespace.class)) {
String innerNamespace = method.getAnnotation(Namespace.class)
.value();
methods.putAll(_describe(
method.getActualMethod().invoke(c, (Object[]) null),