Class BaseProtoSchemaGenerator

  • Direct Known Subclasses:
    RuntimeProtoSchemaGenerator

    public abstract class BaseProtoSchemaGenerator
    extends Object
    Generates a protobuf schema (proto file) based on annotations and also generates marshallers for the types.

    This class is not to be directly invoked by users. See ProtoSchemaBuilder instead.

    Generators are not expected to be stateless, so reuse must be done taking this into account.

    Since:
    3.0
    Author:
    [email protected]
    • Field Detail

      • generateSchemaDebugComments

        public static boolean generateSchemaDebugComments
        Set this flag to true to enable output of debug comments in the generated Protobuf schema.
      • generateMarshallerDebugComments

        public static boolean generateMarshallerDebugComments
        Set this flag to true to enable output of debug comments in the generated marshaller source code.
      • fileName

        protected final String fileName
        Protobuf schema file name.
      • generator

        protected final String generator
      • packageName

        protected final String packageName
        Protobuf schema package name.
      • classes

        protected final Set<XClass> classes
        Initial set of classes.
      • autoImportClasses

        protected final boolean autoImportClasses
        Indicates if class dependencies are automatically added when discovered or will generate an error.
    • Method Detail

      • generateAndRegister

        public String generateAndRegister()
      • getMarshalledClasses

        public Set<XClass> getMarshalledClasses()
      • importProtoTypeMetadata

        protected abstract ProtoTypeMetadata importProtoTypeMetadata​(XClass javaType)
        Return an imported ProtoTypeMetadata implementation or null if it cannot be imported.
      • isUnknownClass

        protected boolean isUnknownClass​(XClass c)
      • getAdapterFor

        protected XClass getAdapterFor​(XClass annotatedClass)
      • getTargetClass

        protected XClass getTargetClass​(XClass annotatedClass)
        Get the marshalled class or enum. The marshalled class and the annotated class are not always the same, depending on the presence of the ProtoAdapter annotation which may establish a new target.