Class ProtoSchemaBuilder

    • Constructor Detail

      • ProtoSchemaBuilder

        public ProtoSchemaBuilder()
    • Method Detail

      • fileName

        public ProtoSchemaBuilder fileName​(String fileName)
        Set the name of the Protobuf schema file to generate. This is mandatory. The resulting file will be registered in the SerializationContext with this given name.
        Parameters:
        fileName - the name of the file to generate
        Returns:
        itself
      • packageName

        public ProtoSchemaBuilder packageName​(String packageName)
        Set the name of the Protobuf package to generate. This is optional.
        Parameters:
        packageName - the package name
        Returns:
        itself, to help chaining calls
      • addClass

        public ProtoSchemaBuilder addClass​(Class<?> clazz)
        Add a @ProtoXyz annotated class to be analyzed. Proto schema and marshaller will be generated for it.

        Its superclass and superinterfaces will be also included in the analysis but no separate Protobuf types and marshallers will be generated for them as Protobuf does not have any notion of type hierarchy and inheritance. The fields defined by the superclass or superinterfaces will be just included in the schema of the derived class.

        Its inner classes will also be automatically processed if they are referenced by the outer class. If you want to make sure an inner class is processed regardless if referenced or not you will have to add it explicitly using #addClass or addClasses(java.lang.Class<?>...).

        Parameters:
        clazz - the class to analyze
        Returns:
        itself, to help chaining calls
      • addClasses

        public ProtoSchemaBuilder addClasses​(Class<?>... classes)
        Add several @ProtoXyz annotated classes to be analyzed. Proto schema and marshaller will be generated for them.

        Their superclasses and superinterfaces will be also included in the analysis but no separate Protobuf types and marshallers will be generated for them as Protobuf does not have any notion of type hierarchy and inheritance. The fields defined by the superclass or superinterfaces will be just included in the schema of the derived class.

        Inner classes will also be automatically processed if they are referenced by the outer class. If you want to make sure an inner class is processed regardless if referenced or not you will have to add it explicitly using addClass(java.lang.Class<?>) or #addClasses.

        Parameters:
        classes - the classes to analyze
        Returns:
        itself, to help chaining calls
      • autoImportClasses

        public ProtoSchemaBuilder autoImportClasses​(boolean autoImportClasses)
        A flag to control processing of classes that were not directly added but were discovered by auto-import. When such a class is found an error will be generated if autoImportClasses is turned off. This flag is true by default to make your life easier but can be turned off when you need to be very specific about which classes are to be processed.
        Parameters:
        autoImportClasses -
        Returns:
        itself, to help chaining calls