/**
* Amount of field and method references pointing to this class.
*/
- private int referenceCount = 0;
+ private int incomingReferencesCount = 0;
public ClassDescriptor(final Class<? extends Object> clazz,
final ClassGraph dump) {
}
public boolean areReferencesShown() {
- return referenceCount <= MAX_REFERECNES_COUNT;
+ return incomingReferencesCount <= MAX_REFERECNES_COUNT;
}
public void enlistFieldReferences(final StringBuffer result) {
isShown = false;
}
+ public boolean hideClassIfNoReferences() {
+ if (!isVisible())
+ return false;
+
+ int outgoingVisibleReferencesCount = 0;
+
+ for (final MethodDescriptor methodDescriptor : methods)
+ outgoingVisibleReferencesCount += methodDescriptor
+ .getOutsideVisibleReferencesCount();
+
+ for (final FieldDescriptor fieldDescriptor : nameToFieldMap.values())
+ outgoingVisibleReferencesCount += fieldDescriptor
+ .getOutsideVisibleReferencesCount();
+
+ final int totalReferencesCount = outgoingVisibleReferencesCount
+ + incomingReferencesCount;
+
+ if (totalReferencesCount == 0) {
+ hide();
+ return true;
+ }
+
+ return false;
+ }
+
public void indexFields(final Field[] fields) {
for (final Field field : fields) {
if (nameToFieldMap.containsKey(field.getName()))
}
public void registerReference() {
- referenceCount++;
+ incomingReferencesCount++;
}
public void setDistinctiveColor(final String distinctiveColor) {
public class ClassGraph {
+ public static void render(final String graphName, final Class... classes) {
+ final ClassGraph classGraph = new ClassGraph();
+
+ for (final Class clazz : classes)
+ classGraph.addClass(clazz);
+
+ classGraph.generateGraph(graphName);
+ }
+
/**
* Maps class fully qualified names to class descriptors.
*/
return resultStr;
}
+ public void hideClassesWithoutReferences() {
+
+ for (final ClassDescriptor classDescriptor : nameToClassMap.values())
+ classDescriptor.hideClassIfNoReferences();
+
+ }
+
}