/** * Generate a .dot file which can be fed into GraphViz for layout and visualization of the class graph. Methods * and fields are shown, if method and field info have been enabled respectively, via * {@link io.github.lukehutch.fastclasspathscanner.FastClasspathScanner#enableMethodInfo()} and * {@link io.github.lukehutch.fastclasspathscanner.FastClasspathScanner#enableFieldInfo()}. Only public * methods/fields are shown, unless * {@link io.github.lukehutch.fastclasspathscanner.FastClasspathScanner#ignoreMethodVisibility()} and/or * {@link io.github.lukehutch.fastclasspathscanner.FastClasspathScanner#ignoreFieldVisibility()} has been * called. The size defaults to 10.5 x 8 inches. * * @return the GraphViz file contents. */ public String generateClassGraphDotFile() { return classGraphBuilder.generateClassGraphDotFile(/* sizeX = */ 10.5f, /* sizeY = */ 8f, /* showFields = */ true, /* showMethods = */ true); }
/** * Get a map from class name to ClassInfo object for all whitelisted classes found during the scan. You can get * the info for a specific class directly from this map, or the values() of this map may be filtered using Java * 8 stream processing, see here: * * <p> * https://github.com/lukehutch/fast-classpath-scanner/wiki/1.-Usage#mechanism-3 * * @return A map from class name to ClassInfo object for the class. */ public Map<String, ClassInfo> getClassNameToClassInfo() { return classGraphBuilder.getClassNameToClassInfo(); }
/** * Get the names of all annotation classes found during the scan. * * @return The sorted list of the names of all annotation classes found during the scan, or the empty list if * none. */ public List<String> getNamesOfAllAnnotationClasses() { return classGraphBuilder.getNamesOfAllAnnotationClasses(); }
buf.append("edge [fontname = \"Courier, Regular\"]\n"); final Set<ClassInfo> standardClassNodes = ClassInfo.filterClassInfo(allClassInfo(), /* removeExternalClassesIfStrictWhitelist = */ true, scanSpec, ClassType.STANDARD_CLASS); final ClassInfo objectClass = classNameToClassInfo.get("java.lang.Object"); final Set<ClassInfo> interfaceNodes = ClassInfo.filterClassInfo(allClassInfo(), /* removeExternalClassesIfStrictWhitelist = */ true, scanSpec, ClassType.IMPLEMENTED_INTERFACE); final Set<ClassInfo> annotationNodes = ClassInfo.filterClassInfo(allClassInfo(), /* removeExternalClassesIfStrictWhitelist = */ true, scanSpec, ClassType.ANNOTATION); labelClassNodeHTML(node, "box", "fff2b6", showFields, showMethods, buf); buf.append(";\n"); labelClassNodeHTML(node, "diamond", "b6e7ff", showFields, showMethods, buf); buf.append(";\n"); labelClassNodeHTML(node, "oval", "f3c9ff", showFields, showMethods, buf); buf.append(";\n"); for (final ClassInfo fieldTypeNode : lookup( classNode.getClassNamesReferencedInFieldTypeDescriptors())) { if (allVisibleNodes.contains(fieldTypeNode)) { for (final ClassInfo fieldTypeNode : lookup( classNode.getClassNamesReferencedInMethodTypeDescriptors())) { if (allVisibleNodes.contains(fieldTypeNode)) {
/** * Get the sorted unique names of all standard (non-interface/annotation) classes found during the scan. */ List<String> getNamesOfAllStandardClasses() { return ClassInfo.getNamesOfAllStandardClasses(scanSpec, allClassInfo()); }
classNameToClassInfo.put(ci.getClassName(), ci); final ClassGraphBuilder classGraphBuilder = new ClassGraphBuilder(deserialized.scanSpec, classNameToClassInfo); final ScanResult scanResult = new ScanResult(deserialized.scanSpec, /* fileToLastModified = */ null, /* nestedJarHandler = */ null, /* interruptionChecker = */ null, classGraphBuilder.setFields(deserialized.scanSpec, scanResult); return scanResult;
/** * Get the names of all classes, interfaces and annotations found during the scan. * * @return The sorted list of the names of all whitelisted classes found during the scan, or the empty list if * none. */ public List<String> getNamesOfAllClasses() { return classGraphBuilder.getNamesOfAllClasses(); }
/** * Get the names of all interface classes found during the scan. * * @return The sorted list of the names of all whitelisted interfaces found during the scan, or the empty list * if none. */ public List<String> getNamesOfAllInterfaceClasses() { return classGraphBuilder.getNamesOfAllInterfaceClasses(); }
/** * Get the names of all standard (non-interface/non-annotation) classes found during the scan. * * @return The sorted list of the names of all encountered standard classes, or the empty list if none. */ public List<String> getNamesOfAllStandardClasses() { return classGraphBuilder.getNamesOfAllStandardClasses(); }
/** * Get the names of all annotations and meta-annotations on the named class. * * @param className * The class name. * @return The sorted list of the names of annotations and meta-annotations on the named class, or the empty * list if none. */ public List<String> getNamesOfAnnotationsOnClass(final String className) { return classGraphBuilder.getNamesOfAnnotationsOnClass(className); }
/** * Find the classloader(s) for the named class. Typically there will only be one ClassLoader returned. However, * if more than one is returned, they should be called in turn until one is able to load the class. * * @param className * The class name. * @return The classloader(s) for the named class. */ public ClassLoader[] getClassLoadersForClass(final String className) { final Map<String, ClassLoader[]> classNameToClassLoaders = classGraphBuilder.getClassNameToClassLoaders(); if (classNameToClassLoaders != null) { final ClassLoader[] classLoaders = classNameToClassLoaders.get(className); if (classLoaders != null) { return classLoaders; } } // Default to default classloader order if classpath element didn't have specified classloader(s) return envClassLoaderOrder; }
final ClassGraphBuilder classGraphBuilder = new ClassGraphBuilder(scanSpec, classNameToClassInfo); if (classGraphLog != null) { classGraphLog.addElapsedTime();
/** * Get the sorted unique names of all classes, interfaces and annotations found during the scan. */ List<String> getNamesOfAllClasses() { return ClassInfo.getNamesOfAllClasses(scanSpec, allClassInfo()); }
/** Return a sorted list of classes that have a field with the named annotation. */ List<String> getNamesOfClassesWithFieldAnnotation(final String annotationName) { return ClassInfo.getNamesOfClassesWithFieldAnnotation(annotationName, allClassInfo()); }
/** * Generate a .dot file which can be fed into GraphViz for layout and visualization of the class graph. Methods * and fields are shown, if method and field info have been enabled respectively, via * {@link io.github.lukehutch.fastclasspathscanner.FastClasspathScanner#enableMethodInfo()} and * {@link io.github.lukehutch.fastclasspathscanner.FastClasspathScanner#enableFieldInfo()}. Only public * methods/fields are shown, unless * {@link io.github.lukehutch.fastclasspathscanner.FastClasspathScanner#ignoreMethodVisibility()} and/or * {@link io.github.lukehutch.fastclasspathscanner.FastClasspathScanner#ignoreFieldVisibility()} has been * called. The sizeX and sizeY parameters are the image output size to use (in inches) when GraphViz is asked to * render the .dot file. * * @param sizeX * The GraphViz layout width in inches. * @param sizeY * The GraphViz layout width in inches. * @return the GraphViz file contents. */ public String generateClassGraphDotFile(final float sizeX, final float sizeY) { return classGraphBuilder.generateClassGraphDotFile(sizeX, sizeY, /* showFields = */ true, /* showMethods = */ true); }
/** Return a sorted list of classes that have a method with the named annotation. */ List<String> getNamesOfClassesWithMethodAnnotation(final String annotationName) { return ClassInfo.getNamesOfClassesWithMethodAnnotation(annotationName, allClassInfo()); }
return classGraphBuilder.generateClassGraphDotFile(sizeX, sizeY, showFields, showMethods);
/** Return the sorted unique names of all annotation classes found during the scan. */ List<String> getNamesOfAllAnnotationClasses() { return ClassInfo.getNamesOfAllAnnotationClasses(scanSpec, allClassInfo()); }
/** Return the sorted unique names of all interface classes found during the scan. */ List<String> getNamesOfAllInterfaceClasses() { return ClassInfo.getNamesOfAllInterfaceClasses(scanSpec, allClassInfo()); }