java.lang.Object
org.springframework.aot.test.generate.compile.Compiled

public class Compiled extends Object
Fully compiled results provided from a TestCompiler.
Since:
6.0
Author:
Phillip Webb
  • Method Details

    • getClassLoader

      public ClassLoader getClassLoader()
      Return the classloader containing the compiled content and access to the resources.
      Returns:
      the classLoader
    • getSourceFile

      public SourceFile getSourceFile()
      Return the single source file that was compiled.
      Returns:
      the single source file
      Throws:
      IllegalStateException - if the compiler wasn't passed exactly one file
    • getSourceFile

      public SourceFile getSourceFile(String pattern)
      Return the single matching source file that was compiled.
      Parameters:
      pattern - the pattern used to find the file
      Returns:
      the single source file
      Throws:
      IllegalStateException - if the compiler wasn't passed exactly one file
    • getSourceFileFromPackage

      public SourceFile getSourceFileFromPackage(String packageName)
      Return the single source file that was compiled in the given package.
      Parameters:
      packageName - the package name to check
      Returns:
      the single source file
      Throws:
      IllegalStateException - if the compiler wasn't passed exactly one file
    • getSourceFiles

      public SourceFiles getSourceFiles()
      Return all source files that were compiled.
      Returns:
      the source files used by the compiler
    • getResourceFile

      public ResourceFile getResourceFile()
      Return the single resource file that was used when compiled.
      Returns:
      the single resource file
      Throws:
      IllegalStateException - if the compiler wasn't passed exactly one file
    • getResourceFiles

      public ResourceFiles getResourceFiles()
      Return all resource files that were compiled.
      Returns:
      the resource files used by the compiler
    • getInstance

      public <T> T getInstance(Class<T> type)
      Return a new instance of a compiled class of the given type. There must be only a single instance and it must have a default constructor.
      Type Parameters:
      T - the required type
      Parameters:
      type - the required type
      Returns:
      an instance of type created from the compiled classes
      Throws:
      IllegalStateException - if no instance can be found or instantiated
    • getInstance

      public <T> T getInstance(Class<T> type, String className)
      Return an instance of a compiled class identified by its class name. The class must have a default constructor.
      Type Parameters:
      T - the type to return
      Parameters:
      type - the type to return
      className - the class name to load
      Returns:
      an instance of the class
      Throws:
      IllegalStateException - if no instance can be found or instantiated
    • getAllCompiledClasses

      public List<Class<?>> getAllCompiledClasses()
      Return all compiled classes.
      Returns:
      a list of all compiled classes