[Java] Class ClassFinder
- org.codehaus.groovy.vmplugin.v9.ClassFinder
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)
- Since:
- 3.0.2
Methods Summary
Type Params | Return Type | Name and description |
---|---|---|
public static Map<String, Set<String>> |
find(URI classpathEntryURI, String packageName) Returns the found classes | |
public static Map<String, Set<String>> |
find(URI classpathEntryURI, String packageName, boolean recursive) Returns the found classes | |
public FileVisitResult |
preVisitDirectory(Path path, BasicFileAttributes attrs) | |
public FileVisitResult |
visitFile(Path path, BasicFileAttributes attrs) |
Inherited Methods Summary
Methods inherited from class | Name |
---|---|
class Object | wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Method Detail
public static Map<String, Set<String>> find(URI classpathEntryURI, String packageName)
Returns the found classes
- Parameters:
-
classpathEntryURI
- the classpath entry -
packageName
- the package under which we find classes
- Returns:
- the found classes
- Since:
- 3.0.2
public static Map<String, Set<String>> find(URI classpathEntryURI, String packageName, boolean recursive)
Returns the found classes
- Parameters:
-
classpathEntryURI
- the classpath entry -
packageName
- the package under which we find classes -
recursive
- whether to find sub-packages
- Returns:
- the found classes
- Since:
- 3.0.2
@Override public FileVisitResult preVisitDirectory(Path path, BasicFileAttributes attrs)
@Override public FileVisitResult visitFile(Path path, BasicFileAttributes attrs)
© 2003-2020 The Apache Software Foundation
Licensed under the Apache license.
https://docs.groovy-lang.org/3.0.7/html/gapi/org/codehaus/groovy/vmplugin/v9/ClassFinder.html