Interface ClassResolver

All Known Implementing Classes:
ClassResolverFromClasspath, SelectedClassResolverFromClasspath

public interface ClassResolver
The ClassFileImporter will use the configured ClassResolver, to determine how to resolve further dependencies.

For example, if you import the package, and some class calls a method of com.other.Dependency, the ClassResolver will decide how this dependency should be treated, i.e. should the class tried to be located somehow, e.g. on the classpath, or should instead a stub with the respective type name be created.

Before any call of tryResolve(String), ArchUnit will always call setClassUriImporter(ClassUriImporter) and supply a respective ClassUriImporter. Thus the job of ClassResolver is just, to resolve the correct URI, where to locate the class. The ClassUriImporter can then import any given URI as a JavaClass.
  • Method Details

    • setClassUriImporter

      void setClassUriImporter​(ClassResolver.ClassUriImporter classUriImporter)
      Always called BEFORE tryResolve(String).
      classUriImporter - to import a JavaClass from any supplied URI
    • tryResolve

      Optional<JavaClass> tryResolve​(java.lang.String typeName)
      ArchUnit will call this method, to resolve any missing JavaClasses, needed to build the class graph (i.e. targets of method calls, field accesses, super classes, interfaces, ...)
      typeName - The type name to resolve as JavaClass
      Optional.of(resolvedClass), if the JavaClass could be successfully imported, otherwise Optional.absent()