Class AbstractByteCodeGenerator

java.lang.Object
io.micronaut.sourcegen.generator.AbstractByteCodeGenerator
All Implemented Interfaces:
SourceGenerator
Direct Known Subclasses:
ByteCodeGenerator, ByteCodeGenerator

@Internal public abstract class AbstractByteCodeGenerator extends Object implements SourceGenerator
Common class-output and member-type traversal for bytecode generators.

A backend returns whether it emitted the definition itself. A source fallback can return false when its source already contains member types; this prevents those types from being emitted a second time by the traversal.

Since:
2.2
  • Constructor Details

    • AbstractByteCodeGenerator

      public AbstractByteCodeGenerator()
  • Method Details

    • write

      public final void write(ObjectDef objectDef, Writer writer)
      Description copied from interface: SourceGenerator
      Write the source code.
      Specified by:
      write in interface SourceGenerator
      Parameters:
      objectDef - The object definition
      writer - The writer
    • write

      public final void write(ObjectDef objectDef, io.micronaut.inject.visitor.VisitorContext context, io.micronaut.inject.ast.Element... originatingElements)
      Description copied from interface: SourceGenerator
      Write the file using the context.
      Specified by:
      write in interface SourceGenerator
      Parameters:
      objectDef - The object to write
      context - The context
      originatingElements - the originated elements
    • writeClass

      protected abstract boolean writeClass(ObjectDef objectDef, @Nullable ClassTypeDef outerType, io.micronaut.inject.visitor.VisitorContext context, io.micronaut.inject.ast.Element[] originatingElements) throws Exception
      Emit one definition.
      Parameters:
      objectDef - The definition
      outerType - The enclosing type, or null
      context - The visitor context
      originatingElements - Originating elements
      Returns:
      true when member definitions should be traversed
      Throws:
      Exception - If emission fails