Class Locations

java.lang.Object
com.tngtech.archunit.core.importer.Locations

@PublicAPI(usage=ACCESS) public final class Locations extends Object
Represents a set of locations of Java class files. Also offers methods to derive concrete locations (i.e. URIs) from higher level concepts like packages or the classpath.
  • Method Details

    • of

      @PublicAPI(usage=ACCESS) public static Set<Location> of(Iterable<URL> urls)
      Directly converts the passed URLs to locations. URLs can be of class files as well as directories. They can also be JAR URLs of class files (e.g. jar:file:///some.jar!/some/Example.class) or folders within JAR files.
      Parameters:
      urls - URLs to directly convert to locations
      Returns:
      Locations representing the passed URLs
    • ofPackage

      @PublicAPI(usage=ACCESS) public static Set<Location> ofPackage(String pkg)
      All locations in the classpath that match the supplied package.
      Parameters:
      pkg - the package to look for within the classpath
      Returns:
      Locations of all paths that match the supplied package
    • ofClass

      @PublicAPI(usage=ACCESS) public static Set<Location> ofClass(Class<?> clazz)
      Set of locations where the class file of the supplied class can be found.
      Note that this is really a set, since the same (or in bad cases a different version of the same) class might be found within the classpath several times.
      Parameters:
      clazz - A Class to import
      Returns:
      Locations of the respective class file within the classpath
    • inClassPath

      @PublicAPI(usage=ACCESS) public static Set<Location> inClassPath()
      Returns:
      All classes that can be found within the classpath. Note that ArchUnit does not distinguish between the classpath and the modulepath, thus for Java >= 9 all locations of class files from the modulepath with be returned as well.