Class ClassFinder

java.lang.Object
org.codehaus.groovy.vmplugin.v9.ClassFinder

public class ClassFinder
extends java.lang.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
  • Method Summary

    Modifier and Type Method Description
    static java.util.Map<java.lang.String,​java.util.Set<java.lang.String>> find​(java.net.URI classpathEntryURI, java.lang.String packageName)
    Returns the found classes
    static java.util.Map<java.lang.String,​java.util.Set<java.lang.String>> find​(java.net.URI classpathEntryURI, java.lang.String packageName, boolean recursive)
    Returns the found classes

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • find

      public static java.util.Map<java.lang.String,​java.util.Set<java.lang.String>> find​(java.net.URI classpathEntryURI, java.lang.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
    • find

      public static java.util.Map<java.lang.String,​java.util.Set<java.lang.String>> find​(java.net.URI classpathEntryURI, java.lang.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