@SuppressWarnings("deprecation") public static Type resolveType(String typeName, ClassDoc klass, JAXDoclet<?> doclet) { log("resolving " + typeName + " in " + klass.qualifiedTypeName()); // first look in inner classes for (ClassDoc innerClass : klass.innerClasses(false)) { if (innerClass.simpleTypeName().equals(typeName)) return innerClass; } // then the class itself if (klass.typeName().equals(typeName)) return klass; try { // then go through the named imports for (ClassDoc importedClass : klass.importedClasses()) { if (importedClass.typeName().equals(typeName)) return importedClass; } // then the package imports for (PackageDoc importedPackage : klass.importedPackages()) { for (ClassDoc importedClass : importedPackage.allClasses(false)) { if (importedClass.typeName().equals(typeName)) return importedClass; } } } catch (NullPointerException e) { } // now try FQDN Type type = doclet.forName(typeName); if (type != null) return type; log("resolving failed for " + typeName + " in " + klass.qualifiedTypeName()); return null; }
public static Type getCollectionType(Type type, JAXDoclet<?> doclet) { Type collectionType = Utils.findSuperType(type, "java.util.Collection"); // FIXME: this is dodgy at best if (collectionType != null) { ParameterizedType parameterizedType = type.asParameterizedType(); Type[] types = parameterizedType == null ? null : parameterizedType.typeArguments(); if (types != null && types.length == 1) return types[0]; return doclet.forName("java.lang.Object"); } return type; }