コード例 #1
0
 /**
  * 生成JAVA方法
  *
  * @param cl
  * @param method
  * @return {@link JavaMethod}
  */
 @SuppressWarnings("rawtypes")
 public JavaMethod createJavaMethod(Class cl, String method) {
   JavaClass clazz = createJaveClass(cl);
   for (JavaMethod m : clazz.getMethods()) {
     if (m.getMethodName().equals(method)) {
       return m;
     }
   }
   throw new RuntimeException("not found method:" + method);
 }
コード例 #2
0
 /**
  * 取得JAVA方法
  *
  * @param javaClass
  * @param cl
  * @return {@link List}
  */
 @SuppressWarnings("rawtypes")
 private List<JavaMethod> getJaveClassMethod(JavaClass javaClass, Class cl) {
   List<JavaMethod> javaMethods = new ArrayList<JavaMethod>();
   Method[] methods = cl.getDeclaredMethods();
   for (int i = 0; i < methods.length; i++) {
     Method method = methods[i];
     JavaMethod javaMethod = new JavaMethod();
     javaMethod.setMethodName(method.getName());
     javaMethod.setClazz(javaClass);
     MethodParameter returnValue = new MethodParameter();
     returnValue.setMethod(javaMethod);
     returnValue.setName("returnValue");
     returnValue.setJavaType(method.getReturnType().getName());
     javaMethod.setReturnType(returnValue);
     List<MethodParameter> parameters = getJavaClassField(javaMethod, method);
     javaMethod.setParameters(parameters);
     javaMethods.add(javaMethod);
   }
   return javaMethods;
 }