Updated copyright info
[javainspect.git] / src / main / java / eu / svjatoslav / inspector / java / structure / MethodDescriptor.java
index d411cb0..96825fd 100755 (executable)
@@ -1,6 +1,6 @@
 /*
  * JavaInspect - Utility to visualize java software
- * Copyright (C) 2013-2015, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
+ * Copyright (C) 2013-2020, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of version 3 of the GNU Lesser General Public License
@@ -23,7 +23,7 @@ public class MethodDescriptor implements GraphElement,
 
     private final String methodName;
     private final ClassDescriptor parentClass;
-    private final List<ClassDescriptor> argumentTypes = new ArrayList<ClassDescriptor>();
+    private final List<ClassDescriptor> argumentTypes = new ArrayList<>();
     private ClassDescriptor returnType;
     private boolean isInherited;
 
@@ -86,7 +86,7 @@ public class MethodDescriptor implements GraphElement,
         if (!isVisible())
             return "";
 
-        final StringBuffer result = new StringBuffer();
+        final StringBuilder result = new StringBuilder();
 
         // describe associated types
         for (final ClassDescriptor classDescriptor : argumentTypes)
@@ -98,8 +98,8 @@ public class MethodDescriptor implements GraphElement,
                             + classDescriptor.getColor()
                             + "\", style=\"dotted, bold\"];\n");
 
-        if (!returnType.isVisible())
-            return result.toString();
+        if (returnType == null) return result.toString();
+        if (!returnType.isVisible()) return result.toString();
 
         // main type
         if (returnType.areReferencesShown())
@@ -116,12 +116,12 @@ public class MethodDescriptor implements GraphElement,
         if (!isVisible())
             return "";
 
-        final StringBuffer result = new StringBuffer();
+        final StringBuilder result = new StringBuilder();
 
         result.append("        // " + methodName + "\n");
 
         result.append("        <TR><td ALIGN=\"right\">"
-                + "<FONT POINT-SIZE=\"8.0\">" + returnType.getClassName(true)
+                + "<FONT POINT-SIZE=\"8.0\">" + describeReturnType()
                 + "</FONT>" + "</td><TD PORT=\"" + getMethodLabel()
                 + "\" ALIGN=\"left\"><FONT COLOR =\"red\" POINT-SIZE=\"11.0\">"
                 + getMethodLabel() + "</FONT></TD></TR>\n");
@@ -129,6 +129,12 @@ public class MethodDescriptor implements GraphElement,
         return result.toString();
     }
 
+    private String describeReturnType() {
+        if (returnType == null) return "-null-";
+
+        return returnType.getClassName(true);
+    }
+
     @Override
     public String getGraphId() {
         return parentClass.getGraphId() + ":" + methodName;
@@ -141,8 +147,9 @@ public class MethodDescriptor implements GraphElement,
     protected int getOutsideVisibleReferencesCount() {
         int result = 0;
 
-        if (returnType.isVisible())
-            result++;
+        if (returnType != null)
+            if (returnType.isVisible())
+                result++;
 
         for (final ClassDescriptor classDescriptor : argumentTypes)
             if (classDescriptor.isVisible())