示例#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 clazz
  * @return {@link JavaClass}
  */
 @SuppressWarnings("rawtypes")
 public JavaClass createJaveClass(Class clazz) {
   JavaClass javaClass = new JavaClass();
   javaClass.setClassName(clazz.getSimpleName());
   javaClass.setPackageName(clazz.getPackage().getName());
   if (clazz.getSuperclass() != null) {
     javaClass.setSuperclassName(clazz.getSuperclass().getName());
   }
   List<JavaClassField> javaClassFields = getJaveClassFields(javaClass, clazz);
   javaClass.setFields(javaClassFields);
   List<JavaMethod> javaMethods = getJaveClassMethod(javaClass, clazz);
   javaClass.setMethods(javaMethods);
   return javaClass;
 }