Interface ClassWriterOutputVisitor

All Known Subinterfaces:
BeanElementVisitorContext, VisitorContext
All Known Implementing Classes:
AbstractClassWriterOutputVisitor, AnnotationProcessingOutputVisitor, DirectoryClassWriterOutputVisitor, GroovyVisitorContext, InMemoryClassWriterOutputVisitor, JavaVisitorContext

public interface ClassWriterOutputVisitor
Interface to be consumed by class writers allowing visiting file names and returning appropriate streams.
Author:
Graeme Rocher
  • Method Details

    • visitClass

      default OutputStream visitClass(String classname) throws IOException
      Visits a new class and returns the output stream with which should be written the bytes of the class to be generated.

      Note that this method should only be called from a TypeElementVisitor.VisitorKind.AGGREGATING visitor from within the TypeElementVisitor.finish(io.micronaut.inject.visitor.VisitorContext) method. If the file

      Parameters:
      classname - the fully qualified classname
      Returns:
      the output stream to write to
      Throws:
      IOException - if an error occurs creating the output stream
    • visitClass

      default OutputStream visitClass(String classname, @Nullable @Nullable Element originatingElement) throws IOException
      Visits a new class and returns the output stream with which should be written the bytes of the class to be generated.
      Parameters:
      classname - the fully qualified classname
      originatingElement - The originating element
      Returns:
      the output stream to write to
      Throws:
      IOException - if an error occurs creating the output stream
    • visitClass

      OutputStream visitClass(String classname, Element... originatingElements) throws IOException
      Visits a new class and returns the output stream with which should be written the bytes of the class to be generated.

      Note that this method should only be called from a TypeElementVisitor.VisitorKind.AGGREGATING visitor from within the TypeElementVisitor.finish(io.micronaut.inject.visitor.VisitorContext) method. If the file

      Parameters:
      classname - the fully qualified classname
      originatingElements - The originating elements
      Returns:
      the output stream to write to
      Throws:
      IOException - if an error occurs creating the output stream
    • visitServiceDescriptor

      void visitServiceDescriptor(String type, String classname)
      Allows adding a class that will be written to the META-INF/services file under the given type and class name.
      Parameters:
      type - the fully qualified service name
      classname - the fully qualified classname
    • visitServiceDescriptor

      void visitServiceDescriptor(String type, String classname, Element originatingElement)
      Allows adding a class that will be written to the META-INF/services file under the given type and class name.
      Parameters:
      type - the fully qualified service name
      classname - the fully qualified classname
      originatingElement - The originating element
      Since:
      3.5.0
    • visitMetaInfFile

      @Deprecated default Optional<GeneratedFile> visitMetaInfFile(String path)
      Deprecated.
      Visiting a file should supply the originating elements. Use visitMetaInfFile(String, Element...) instead
      Visit a file within the META-INF directory of the 'classes' directory.
      Parameters:
      path - The path to the file
      Returns:
      An optional file it was possible to create it
    • visitMetaInfFile

      Optional<GeneratedFile> visitMetaInfFile(String path, Element... originatingElements)
      Visit a file within the META-INF directory of the 'classes' directory.
      Parameters:
      path - The path to the file
      originatingElements - The originating elements
      Returns:
      An optional file it was possible to create it
    • visitGeneratedFile

      @Deprecated Optional<GeneratedFile> visitGeneratedFile(String path)
      Visit a file that will be generated within the generated 'sources' directory.
      Parameters:
      path - The path
      Returns:
      The file if it was possible to create it
    • visitGeneratedFile

      Optional<GeneratedFile> visitGeneratedFile(String path, Element... originatingElements)
      Visit a file that will be generated within the generated 'sources' directory.
      Parameters:
      path - The path
      originatingElements - the originating elements
      Returns:
      The file if it was possible to create it
      Since:
      4.0.0
    • visitGeneratedSourceFile

      default Optional<GeneratedFile> visitGeneratedSourceFile(String packageName, String fileNameWithoutExtension, Element... originatingElements)
      Visit a source file that will be generated within the generated 'sources' directory.
      Parameters:
      packageName - The package for the source file
      fileNameWithoutExtension - the name of the source file, without extension (determined automatically)
      originatingElements - the originating elements
      Returns:
      The file if it was possible to create it
      Since:
      4.2.0
    • finish

      void finish()
      Finish writing and flush any service entries to disk.
    • getServiceEntries

      default Map<String,Set<String>> getServiceEntries()
      The META-INF/services entries to write.
      Returns:
      A map of service to class entries
    • visitServiceDescriptor

      @Deprecated default void visitServiceDescriptor(Class<?> type, String classname)
      Allows adding a class that will be written to the META-INF/services file under the given type and class name.
      Parameters:
      type - The service type
      classname - the fully qualified classname
    • visitServiceDescriptor

      default void visitServiceDescriptor(Class<?> type, String classname, Element originatingElement)
      Allows adding a class that will be written to the META-INF/services file under the given type and class name.
      Parameters:
      type - The service type
      classname - the fully qualified classname
      originatingElement - The originating element
      Since:
      3.5.0