private DbJVClass importClass(JavaClass claz, Controller controller) throws DbException { String packName = claz.getPackageName(); String qualifiedName = claz.getClassName(); int idx = qualifiedName.lastIndexOf('.'); String classname = qualifiedName.substring(idx + 1); DbJVClass dbClaz = null; try { if (m_classModel != null) { DbJVPackage pack = findPackageByName(packName); // create class or interface int value = claz.isInterface() ? JVClassCategory.INTERFACE : JVClassCategory.CLASS; JVClassCategory catg = JVClassCategory.getInstance(value); dbClaz = (pack == null) ? new DbJVClass(this.m_classModel, catg) : new DbJVClass(pack, catg); dbClaz.setName(classname); // set class modifiers dbClaz.setAbstract(claz.isAbstract()); dbClaz.setFinal(claz.isFinal()); dbClaz.setStatic(claz.isStatic()); dbClaz.setStrictfp(claz.isStrictfp()); dbClaz.setVisibility(toVisibility(claz)); // create inheritances importInheritances(dbClaz, claz); // create fields if (m_params.createFields) { Field[] fields = claz.getFields(); for (Field field : fields) { importField(dbClaz, field); } } // create methods if (m_params.createMethods) { Method[] methods = claz.getMethods(); for (Method method : methods) { importMethod(dbClaz, method); } } // keep user informed of progression String pattern = LocaleMgr.misc.getString("0SuccessfullyCreated"); String msg = MessageFormat.format(pattern, qualifiedName); controller.println(msg); } // end if } catch (DbException ex) { controller.println(ex.toString()); } // end try return dbClaz; } // end importClass()
private static boolean hasStaticMembers(@NotNull JavaClass javaClass) { for (JavaMethod method : javaClass.getMethods()) { if (method.isStatic() && !shouldBeInEnumClassObject(method)) { return true; } } for (JavaField field : javaClass.getFields()) { if (field.isStatic() && !field.isEnumEntry()) { return true; } } for (JavaClass nestedClass : javaClass.getInnerClasses()) { if (SingleAbstractMethodUtils.isSamInterface(nestedClass)) { return true; } if (nestedClass.isStatic() && hasStaticMembers(nestedClass)) { return true; } } return false; }