use generic type arguments

This commit is contained in:
stfm
2017-11-21 23:24:35 +01:00
parent 86979e36a1
commit ba65694abb
3 changed files with 17 additions and 20 deletions

View File

@@ -18,7 +18,7 @@ import com.sun.javadoc.RootDoc;
*/ */
public class ClassHierachy extends java.lang.Object { public class ClassHierachy extends java.lang.Object {
public SortedMap root = new TreeMap(); public SortedMap<String, SortedMap> root = new TreeMap<>();
/** /**
* Creates new ClassHierachy * Creates new ClassHierachy
@@ -29,17 +29,17 @@ public class ClassHierachy extends java.lang.Object {
/** /**
* Adds another class to the hierachy * Adds another class to the hierachy
*/ */
protected SortedMap add(ClassDoc cls) { protected SortedMap<String, SortedMap> add(ClassDoc cls) {
SortedMap temp; SortedMap<String, SortedMap> temp;
if (cls.superclass() != null) { if (cls.superclass() != null) {
temp = add(cls.superclass()); temp = add(cls.superclass());
} else { } else {
temp = root; temp = root;
} }
SortedMap result = (SortedMap) temp.get(cls.qualifiedName()); SortedMap<String, SortedMap> result = temp.get(cls.qualifiedName());
if (result == null) { if (result == null) {
result = new TreeMap(); result = new TreeMap<String, SortedMap>();
temp.put(cls.qualifiedName(), result); temp.put(cls.qualifiedName(), result);
} }
return result; return result;

View File

@@ -18,7 +18,7 @@ import com.sun.javadoc.RootDoc;
*/ */
public class InterfaceHierachy extends java.lang.Object { public class InterfaceHierachy extends java.lang.Object {
public SortedMap root = new TreeMap(); public SortedMap<String, SortedMap> root = new TreeMap<>();
/** /**
* Creates new InterfaceHierachy * Creates new InterfaceHierachy
@@ -29,17 +29,17 @@ public class InterfaceHierachy extends java.lang.Object {
/** /**
* Adds another interface to the hierachy * Adds another interface to the hierachy
*/ */
protected SortedMap add(ClassDoc cls) { protected SortedMap<String, SortedMap> add(ClassDoc cls) {
SortedMap temp; SortedMap<String, SortedMap> temp;
if (cls.interfaces().length > 0) { if (cls.interfaces().length > 0) {
temp = add(cls.interfaces()[0]); temp = add(cls.interfaces()[0]);
} else { } else {
temp = root; temp = root;
} }
SortedMap result = (SortedMap) temp.get(cls.qualifiedName()); SortedMap<String, SortedMap> result = temp.get(cls.qualifiedName());
if (result == null) { if (result == null) {
result = new TreeMap(); result = new TreeMap<>();
temp.put(cls.qualifiedName(), result); temp.put(cls.qualifiedName(), result);
} }
return result; return result;
@@ -57,12 +57,12 @@ public class InterfaceHierachy extends java.lang.Object {
* Prints a branch of the tree. The branch is printed using * Prints a branch of the tree. The branch is printed using
* <CODE>TeXDoclet.os</CODE>. * <CODE>TeXDoclet.os</CODE>.
*/ */
protected void printBranch(RootDoc rootDoc, SortedMap map, double indent, protected void printBranch(RootDoc rootDoc, SortedMap<String, SortedMap> map, double indent,
double overviewindent) { double overviewindent) {
Set set = map.keySet(); Set<String> set = map.keySet();
Iterator it = set.iterator(); Iterator<String> it = set.iterator();
while (it.hasNext()) { while (it.hasNext()) {
String qualifName = (String) it.next(); String qualifName = it.next();
ClassDoc cls = rootDoc.classNamed(qualifName); ClassDoc cls = rootDoc.classNamed(qualifName);
TeXDoclet.os.print("\\hspace{" + Double.toString(indent) TeXDoclet.os.print("\\hspace{" + Double.toString(indent)
+ "cm} $\\bullet$ " + "cm} $\\bullet$ "
@@ -71,7 +71,7 @@ public class InterfaceHierachy extends java.lang.Object {
TeXDoclet.printRef(cls.containingPackage(), cls.name(), ""); TeXDoclet.printRef(cls.containingPackage(), cls.name(), "");
} }
TeXDoclet.os.println("} \\\\"); TeXDoclet.os.println("} \\\\");
printBranch(rootDoc, (SortedMap) map.get(qualifName), indent printBranch(rootDoc, map.get(qualifName), indent
+ overviewindent, overviewindent); + overviewindent, overviewindent);
} }

View File

@@ -75,12 +75,9 @@ public class Package {
* Sorts the vectors of classes, interfaces exceptions and errors. * Sorts the vectors of classes, interfaces exceptions and errors.
*/ */
public void sort() { public void sort() {
Comparator<ClassDoc> comp = new Comparator<ClassDoc>() {
Comparator comp = new Comparator() {
@Override @Override
public int compare(Object o1, Object o2) { public int compare(ClassDoc cls1, ClassDoc cls2) {
ClassDoc cls1 = (ClassDoc) o1;
ClassDoc cls2 = (ClassDoc) o2;
return cls1.name().compareToIgnoreCase(cls2.name()); return cls1.name().compareToIgnoreCase(cls2.name());
} }