Package io.micronaut.inject.writer
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 Summary
Modifier and TypeMethodDescriptionvoidfinish()Finish writing and flush any service entries to disk.The META-INF/services entries to write.default OutputStreamvisitClass(String classname) Visits a new class and returns the output stream with which should be written the bytes of the class to be generated.default OutputStreamvisitClass(String classname, @Nullable Element originatingElement) Visits a new class and returns the output stream with which should be written the bytes of the class to be generated.visitClass(String classname, Element... originatingElements) Visits a new class and returns the output stream with which should be written the bytes of the class to be generated.visitGeneratedFile(String path) Deprecated.visitGeneratedFile(String path, Element... originatingElements) Visit a file that will be generated within the generated 'sources' directory.default Optional<GeneratedFile>visitGeneratedSourceFile(String packageName, String fileNameWithoutExtension, Element... originatingElements) Visit a source file that will be generated within the generated 'sources' directory.default Optional<GeneratedFile>visitMetaInfFile(String path) Deprecated.Visiting a file should supply the originating elements.visitMetaInfFile(String path, Element... originatingElements) Visit a file within the META-INF directory of the 'classes' directory.default voidvisitServiceDescriptor(Class<?> type, String classname) default voidvisitServiceDescriptor(Class<?> type, String classname, Element originatingElement) Allows adding a class that will be written to theMETA-INF/servicesfile under the given type and class name.voidvisitServiceDescriptor(String type, String classname) Allows adding a class that will be written to theMETA-INF/servicesfile under the given type and class name.voidvisitServiceDescriptor(String type, String classname, Element originatingElement) Allows adding a class that will be written to theMETA-INF/servicesfile under the given type and class name.
-
Method Details
-
visitClass
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.AGGREGATINGvisitor from within theTypeElementVisitor.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 classnameoriginatingElement- The originating element- Returns:
- the output stream to write to
- Throws:
IOException- if an error occurs creating the output stream
-
visitClass
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.AGGREGATINGvisitor from within theTypeElementVisitor.finish(io.micronaut.inject.visitor.VisitorContext)method. If the file- Parameters:
classname- the fully qualified classnameoriginatingElements- The originating elements- Returns:
- the output stream to write to
- Throws:
IOException- if an error occurs creating the output stream
-
visitServiceDescriptor
Allows adding a class that will be written to theMETA-INF/servicesfile under the given type and class name.- Parameters:
type- the fully qualified service nameclassname- the fully qualified classname
-
visitServiceDescriptor
Allows adding a class that will be written to theMETA-INF/servicesfile under the given type and class name.- Parameters:
type- the fully qualified service nameclassname- the fully qualified classnameoriginatingElement- The originating element- Since:
- 3.5.0
-
visitMetaInfFile
Deprecated.Visiting a file should supply the originating elements. UsevisitMetaInfFile(String, Element...)insteadVisit 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
Visit a file within the META-INF directory of the 'classes' directory.- Parameters:
path- The path to the fileoriginatingElements- The originating elements- Returns:
- An optional file it was possible to create it
-
visitGeneratedFile
Deprecated.UsevisitGeneratedFile(String, Element...)insteadVisit 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
Visit a file that will be generated within the generated 'sources' directory.- Parameters:
path- The pathoriginatingElements- 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 filefileNameWithoutExtension- 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
The META-INF/services entries to write.- Returns:
- A map of service to class entries
-
visitServiceDescriptor
Allows adding a class that will be written to theMETA-INF/servicesfile under the given type and class name.- Parameters:
type- The service typeclassname- the fully qualified classname
-
visitServiceDescriptor
Allows adding a class that will be written to theMETA-INF/servicesfile under the given type and class name.- Parameters:
type- The service typeclassname- the fully qualified classnameoriginatingElement- The originating element- Since:
- 3.5.0
-
visitGeneratedFile(String, Element...)instead