Package io.micronaut.inject.writer
Interface ClassWriterOutputVisitor
-
- All Known Subinterfaces:
BeanElementVisitorContext
,VisitorContext
- All Known Implementing Classes:
AbstractClassWriterOutputVisitor
,DirectoryClassWriterOutputVisitor
public interface ClassWriterOutputVisitor
Interface to be consumed by class writers allowing visiting file names and returning appropriate streams.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description void
finish()
Finish writing and flush any service entries to disk.default java.util.Map<java.lang.String,java.util.Set<java.lang.String>>
getServiceEntries()
The META-INF/services entries to write.default java.io.OutputStream
visitClass(java.lang.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 java.io.OutputStream
visitClass(java.lang.String classname, Element originatingElement)
Visits a new class and returns the output stream with which should be written the bytes of the class to be generated.java.io.OutputStream
visitClass(java.lang.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.java.util.Optional<GeneratedFile>
visitGeneratedFile(java.lang.String path)
Visit a file that will be generated within the generated sources directory.default java.util.Optional<GeneratedFile>
visitMetaInfFile(java.lang.String path)
Deprecated.Visiting a file should supply the originating elements.java.util.Optional<GeneratedFile>
visitMetaInfFile(java.lang.String path, Element... originatingElements)
Visit a file within the META-INF directory of the classes directory.default void
visitServiceDescriptor(java.lang.Class<?> type, java.lang.String classname)
default void
visitServiceDescriptor(java.lang.Class<?> type, java.lang.String classname, Element originatingElement)
Allows adding a class that will be written to theMETA-INF/services
file under the given type and class name.void
visitServiceDescriptor(java.lang.String type, java.lang.String classname)
Allows adding a class that will be written to theMETA-INF/services
file under the given type and class name.void
visitServiceDescriptor(java.lang.String type, java.lang.String classname, Element originatingElement)
Allows adding a class that will be written to theMETA-INF/services
file under the given type and class name.
-
-
-
Method Detail
-
visitClass
default java.io.OutputStream visitClass(java.lang.String classname) throws java.io.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 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:
java.io.IOException
- if an error occurs creating the output stream
-
visitClass
default java.io.OutputStream visitClass(java.lang.String classname, @Nullable Element originatingElement) throws java.io.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:
java.io.IOException
- if an error occurs creating the output stream
-
visitClass
java.io.OutputStream visitClass(java.lang.String classname, Element... originatingElements) throws java.io.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 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:
java.io.IOException
- if an error occurs creating the output stream
-
visitServiceDescriptor
void visitServiceDescriptor(java.lang.String type, java.lang.String classname)
Allows adding a class that will be written to theMETA-INF/services
file under the given type and class name.- Parameters:
type
- the fully qualified service nameclassname
- the fully qualified classname
-
visitServiceDescriptor
void visitServiceDescriptor(java.lang.String type, java.lang.String classname, Element originatingElement)
Allows adding a class that will be written to theMETA-INF/services
file 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 default java.util.Optional<GeneratedFile> visitMetaInfFile(java.lang.String path)
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
java.util.Optional<GeneratedFile> visitMetaInfFile(java.lang.String path, Element... originatingElements)
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
java.util.Optional<GeneratedFile> visitGeneratedFile(java.lang.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
-
finish
void finish()
Finish writing and flush any service entries to disk.
-
getServiceEntries
default java.util.Map<java.lang.String,java.util.Set<java.lang.String>> getServiceEntries()
The META-INF/services entries to write.- Returns:
- A map of service to class entries
-
visitServiceDescriptor
@Deprecated default void visitServiceDescriptor(java.lang.Class<?> type, java.lang.String classname)
Allows adding a class that will be written to theMETA-INF/services
file under the given type and class name.- Parameters:
type
- The service typeclassname
- the fully qualified classname
-
visitServiceDescriptor
default void visitServiceDescriptor(java.lang.Class<?> type, java.lang.String classname, Element originatingElement)
Allows adding a class that will be written to theMETA-INF/services
file under the given type and class name.- Parameters:
type
- The service typeclassname
- the fully qualified classnameoriginatingElement
- The originating element- Since:
- 3.5.0
-
-