Class JavaPoetSourceGenerator
java.lang.Object
io.micronaut.sourcegen.JavaPoetSourceGenerator
- All Implemented Interfaces:
SourceGenerator
- Direct Known Subclasses:
GroovyPoetSourceGenerator
@Internal
public sealed class JavaPoetSourceGenerator
extends Object
implements SourceGenerator
permits GroovyPoetSourceGenerator
The Java source generator. Each file is written by renderers of its own, with the context of writing it: the
generator keeps no state.
- Since:
- 1.0
- Author:
- Denis Stepanov
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcustomizeTypeBuilder(ObjectDef objectDef, TypeSpec.Builder typeBuilder) Hook for subclasses to customize the type builder of a class, record, enum or interface before it is built.io.micronaut.inject.visitor.VisitorContext.Languagevoidwrite(ObjectDef objectDef, io.micronaut.inject.visitor.VisitorContext context, boolean markAsGenerated, io.micronaut.inject.ast.Element... originatingElements) Write the file using the context.voidWrite the source code.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface SourceGenerator
write
-
Constructor Details
-
JavaPoetSourceGenerator
public JavaPoetSourceGenerator()
-
-
Method Details
-
write
public void write(ObjectDef objectDef, io.micronaut.inject.visitor.VisitorContext context, boolean markAsGenerated, io.micronaut.inject.ast.Element... originatingElements) Description copied from interface:SourceGeneratorWrite the file using the context.- Specified by:
writein interfaceSourceGenerator- Parameters:
objectDef- The object to writecontext- The contextmarkAsGenerated- Whether to annotate the written types withGeneratedSourceoriginatingElements- the originated elements
-
getLanguage
public io.micronaut.inject.visitor.VisitorContext.Language getLanguage()- Specified by:
getLanguagein interfaceSourceGenerator- Returns:
- The source language of the generator
-
write
Description copied from interface:SourceGeneratorWrite the source code.- Specified by:
writein interfaceSourceGenerator- Parameters:
objectDef- The object definitionwriter- The writer- Throws:
IOException- The IO exception
-
customizeTypeBuilder
Hook for subclasses to customize the type builder of a class, record, enum or interface before it is built. Annotation definitions are not passed through this hook.- Parameters:
objectDef- The object definitiontypeBuilder- The type builder
-