private boolean isShown = true;
- private final ClassGraph dump;
+ private final ClassGraph classGraph;
List<ClassDescriptor> interfaces = new ArrayList<ClassDescriptor>();
public ClassDescriptor(final Class<? extends Object> clazz,
final ClassGraph dump) {
- this.dump = dump;
+ classGraph = dump;
fullyQualifiedName = clazz.getName();
dump.nameToClassMap.put(fullyQualifiedName, this);
continue;
final FieldDescriptor fieldDescriptor = new FieldDescriptor(field,
- this, dump);
+ this, classGraph);
}
}
final Method[] methods = clazz.getMethods();
for (final Method method : methods)
- new MethodDescriptor(method, this, dump);
+ new MethodDescriptor(method, this, classGraph);
}
if (Utils.isSystemPackage(fullyQualifiedName))
return false;
+ if (!classGraph.filter.isClassShown(fullyQualifiedName))
+ return false;
+
return isShown;
}
*/
Map<String, ClassDescriptor> nameToClassMap = new HashMap<String, ClassDescriptor>();
+ public Filter filter = new Filter();
+
public ClassGraph() {
}
--- /dev/null
+package eu.svjatoslav.inspector.java.structure;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import eu.svjatoslav.commons.string.WildCardMatcher;
+
+public class Filter {
+
+ private static final List<String> blacklistedClasses = new ArrayList<String>();
+
+ private static final List<String> whitelistedClasses = new ArrayList<String>();
+
+ public void blacklistClassPattern(final String pattern) {
+ blacklistedClasses.add(pattern);
+ }
+
+ public boolean isClassShown(final String className) {
+ for (final String pattern : blacklistedClasses)
+ if (WildCardMatcher.match(className, pattern))
+ return false;
+
+ if (!whitelistedClasses.isEmpty()) {
+ for (final String pattern : whitelistedClasses)
+ if (WildCardMatcher.match(className, pattern))
+ return true;
+ return false;
+ }
+
+ return true;
+ }
+
+ public void whitelistClassPattern(final String pattern) {
+ whitelistedClasses.add(pattern);
+ }
+
+}