public class ClassFinder extends Object
Find classes under the specified package via some classpath entry Usage:
// find classes under `me.sunlan` package via classpath entry(directory) `D:/_APPS/git_apps/java8-labs/out/production/classes/`
ClassFinder.find(URI.create("file:/D:/_APPS/git_apps/java8-labs/out/production/classes/"), "me/sunlan")
// find classes under `groovy.lang` package via classpath entry(jar file) `D:/_DEV/Groovy/groovy-3.0.1/lib/groovy-3.0.1.jar`
ClassFinder.find(URI.create("file:/D:/_DEV/Groovy/groovy-3.0.1/lib/groovy-3.0.1.jar"), "groovy/lang")
// find classes under `java.lang` package via classpath entry(jrt)
ClassFinder.find(URI.create("jrt:/modules/java.base/"), "java/lang")
// find classes under the sub-packages too, e.g. we can get GroovydocHolder via the following code
ClassFinder.find(URI.create("file:/D:/_DEV/Groovy/groovy-3.0.1/lib/groovy-3.0.1.jar"), "groovy/lang", true)
Type Params | Return Type | Name and description |
---|---|---|
|
static Map<String, Set<String>> |
find(URI classpathEntryURI, String packageName) Returns the found classes |
|
static Map<String, Set<String>> |
find(URI classpathEntryURI, String packageName, boolean recursive) Returns the found classes |
|
FileVisitResult |
preVisitDirectory(Path path, BasicFileAttributes attrs) |
|
FileVisitResult |
visitFile(Path path, BasicFileAttributes attrs) |
Returns the found classes
classpathEntryURI
- the classpath entrypackageName
- the package under which we find classesReturns the found classes
classpathEntryURI
- the classpath entrypackageName
- the package under which we find classesrecursive
- whether to find sub-packages