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

View File

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

View File

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