Class ProtobufMessageFactoryVisitor

java.lang.Object
io.micronaut.protobuf.processor.ProtobufMessageFactoryVisitor
All Implemented Interfaces:
io.micronaut.core.order.Ordered, io.micronaut.core.util.Toggleable, io.micronaut.inject.visitor.TypeElementVisitor<Object,Object>

@Internal public final class ProtobufMessageFactoryVisitor extends Object implements io.micronaut.inject.visitor.TypeElementVisitor<Object,Object>
Generates an io.micronaut.protobuf.ProtobufMessageFactory for every Protocol Buffers message class that protoc generates, so that message builders are created without reflection.

Generated message classes are annotated with @com.google.protobuf.Generated. For each one that implements com.google.protobuf.Message, the visitor writes a small factory class that calls the message's static newBuilder() method, and registers it as a service. Messages in the default package are skipped and keep the reflective fallback.

protoc only annotates the classes it writes to their own file. With the default java_multiple_files = false layout the messages are nested in an outer wrapper class, and only the wrapper carries the annotation, so incremental processing selects just the wrapper. Every visited class is therefore traversed for nested message classes as well.

Since:
5.3.0
  • Nested Class Summary

    Nested classes/interfaces inherited from interface io.micronaut.inject.visitor.TypeElementVisitor

    io.micronaut.inject.visitor.TypeElementVisitor.VisitorKind
  • Field Summary

    Fields inherited from interface io.micronaut.core.order.Ordered

    HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
    io.micronaut.inject.visitor.TypeElementVisitor.VisitorKind
     
    void
    visitClass(io.micronaut.inject.ast.ClassElement element, io.micronaut.inject.visitor.VisitorContext context)
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.micronaut.core.order.Ordered

    getOrder

    Methods inherited from interface io.micronaut.core.util.Toggleable

    isEnabled

    Methods inherited from interface io.micronaut.inject.visitor.TypeElementVisitor

    finish, getClassType, getElementType, getSupportedOptions, query, start, visitConstructor, visitEnumConstant, visitField, visitMethod
  • Constructor Details

    • ProtobufMessageFactoryVisitor

      public ProtobufMessageFactoryVisitor()
  • Method Details

    • getSupportedAnnotationNames

      public Set<String> getSupportedAnnotationNames()
      Specified by:
      getSupportedAnnotationNames in interface io.micronaut.inject.visitor.TypeElementVisitor<Object,Object>
    • getVisitorKind

      public io.micronaut.inject.visitor.TypeElementVisitor.VisitorKind getVisitorKind()
      Specified by:
      getVisitorKind in interface io.micronaut.inject.visitor.TypeElementVisitor<Object,Object>
    • visitClass

      public void visitClass(io.micronaut.inject.ast.ClassElement element, io.micronaut.inject.visitor.VisitorContext context)
      Specified by:
      visitClass in interface io.micronaut.inject.visitor.TypeElementVisitor<Object,Object>