- Comparable<MethodDescriptor> {
-
- /**
- * This class corresponds to single method within a java class.
- */
-
- public String methodName;
- public ClassDescriptor returnType;
- private final ClassDescriptor parentClass;
-
- List<ClassDescriptor> argumentTypes = new ArrayList<ClassDescriptor>();
-
- boolean isInherited;
-
- public MethodDescriptor(final ClassDescriptor parent,
- final String methodName) {
- parentClass = parent;
- this.methodName = methodName;
- }
-
- public void analyze(final Method method) {
-
- if (!method.getDeclaringClass().getName()
- .equals(parentClass.classFullyQualifiedName))
- isInherited = true;
-
- returnType = parentClass.getClassGraph().getOrCreateClassDescriptor(
- method.getReturnType());
- returnType.registerReference();
-
- final Type genericType = method.getGenericReturnType();
- if (genericType instanceof ParameterizedType) {
- final ParameterizedType pt = (ParameterizedType) genericType;
- for (final Type t : pt.getActualTypeArguments())
- if (t instanceof Class) {
- final Class cl = (Class) t;
- final ClassDescriptor classDescriptor = parentClass
- .getClassGraph().getOrCreateClassDescriptor(cl);
- classDescriptor.registerReference();
- argumentTypes.add(classDescriptor);
- }
-
- }
- }
-
- @Override
- public int compareTo(final MethodDescriptor o) {
-
- final int nameComparisonResult = methodName.compareTo(o.methodName);
- if (nameComparisonResult != 0)
- return nameComparisonResult;
-
- return toString().compareTo(o.toString());
- }
-
- @Override
- public String getDot() {
-
- if (!isVisible())
- return "";
-
- final StringBuffer result = new StringBuffer();
-
- // describe associated types
- for (final ClassDescriptor classDescriptor : argumentTypes)
- if (classDescriptor.isVisible())
- if (classDescriptor.areReferencesShown())
- result.append(" " + getGraphId() + " -> "
- + classDescriptor.getGraphId() + "[label=\""
- + methodName + "\", color=\""
- + classDescriptor.getColor()
- + "\", style=\"dotted, bold\"];\n");
-
- if (!returnType.isVisible())
- return result.toString();
-
- // main type
- if (returnType.areReferencesShown())
- result.append(" " + getGraphId() + " -> "
- + returnType.getGraphId() + "[label=\"" + methodName
- + "\"," + " color=\"" + returnType.getColor()
- + "\", style=\"dotted, bold\"];\n");
+ Comparable<MethodDescriptor> {
+
+ private final String methodName;
+ private final ClassDescriptor parentClass;
+ private final List<ClassDescriptor> argumentTypes = new ArrayList<ClassDescriptor>();
+ private ClassDescriptor returnType;
+ private boolean isInherited;
+
+ public MethodDescriptor(final ClassDescriptor parent,
+ final String methodName) {
+ parentClass = parent;
+ this.methodName = methodName;
+ }
+
+ public void analyze(final Method method) {
+
+ if (!method.getDeclaringClass().getName()
+ .equals(parentClass.getFullyQualifiedName()))
+ isInherited = true;
+
+ returnType = parentClass.getClassGraph().getOrCreateClassDescriptor(
+ method.getReturnType());
+ returnType.registerReference();
+
+ final Type genericType = method.getGenericReturnType();
+ if (genericType instanceof ParameterizedType) {
+ final ParameterizedType pt = (ParameterizedType) genericType;
+ for (final Type t : pt.getActualTypeArguments())
+ if (t instanceof Class) {
+ final Class cl = (Class) t;
+ final ClassDescriptor classDescriptor = parentClass
+ .getClassGraph().getOrCreateClassDescriptor(cl);
+ classDescriptor.registerReference();
+ argumentTypes.add(classDescriptor);
+ }
+
+ }
+ }