Annotation Type AutoProtoSchemaBuilder
-
@Target({TYPE,PACKAGE}) @Retention(CLASS) public @interface AutoProtoSchemaBuilder
Generates compile-time auto-implementations ofSerializationContextInitializer
. Annotate a class or interface extending fromSerializationContextInitializer
with this annotation and a new concrete public class named based onclassName()
, having a default no-arguments public constructor will be generated at compile time in the same package. The implementations of the methods fromSerializationContextInitializer
will be generated based on the information provided in the attributes of this annotation.This annotation is used at compile time annotation processing only and should not be relied upon at runtime, so its retention is set to
RetentionPolicy.CLASS
.- Since:
- 4.3
- Author:
- [email protected]
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description boolean
autoImportClasses
Indicates if we accept classes not explicitly included byincludeClasses()
andbasePackages()
to be auto-detected by reference from the already included classes and to be added automatically.String[]
basePackages
The list of packages to scan (optional).String
className
The name of the generated Java implementation class (optional).Class<? extends SerializationContextInitializer>[]
dependsOn
The initializers to execute before this one.Class<?>[]
excludeClasses
Classes to be explicitly excluded.Class<?>[]
includeClasses
Annotated classes to process (optional).String
schemaFileName
The generated Protobuf schema file name (optional).String
schemaFilePath
Generated Protobuf schema resource file path (optional).String
schemaPackageName
Package of the generated Protobuf schema.boolean
service
Enable generation of aMETA-INF/services
file for the generated class of theSerializationContextInitializer
implementation to be loadable by theServiceLoader
.String[]
value
Alias forbasePackages()
.
-
-
-
Element Detail
-
className
String className
The name of the generated Java implementation class (optional). If missing, the name of the current class plus the "Impl" suffix is assumed by default.- Default:
- ""
-
-
-
schemaFileName
String schemaFileName
The generated Protobuf schema file name (optional). It can contain'/'
characters, so it might appear like a relative name. Must end with ".proto" suffix. The schema will be registered under this name in theSerializationContext
. If missing, the simple name of the annotated class will be used plus the ".proto" suffix.- Default:
- ""
-
-
-
schemaFilePath
String schemaFilePath
Generated Protobuf schema resource file path (optional). If this is present then a resource file is generated in the designated path, with the given file name, and will be available to the ClassLoader at runtime, otherwise the generated schema file is directly baked as a String constant into the generated class.- Default:
- ""
-
-
-
schemaPackageName
String schemaPackageName
Package of the generated Protobuf schema. This is optional. If the package name is not specified then the unnamed/default package is assumed.- Default:
- ""
-
-
-
value
String[] value
- Default:
- {}
-
-
-
basePackages
String[] basePackages
The list of packages to scan (optional). The packages are scanned for annotated classes recursively. IfbasePackages
is empty then all packages are considered. The packages are filtered based on theincludeClasses()
/excludeClasses()
filter. If neitherincludeClasses()
norbasePackages
was specified then the entire source path will be scanned. This last option should only be used in very simple demo projects.- Default:
- {}
-
-
-
includeClasses
Class<?>[] includeClasses
Annotated classes to process (optional). These classes must be located in the packages (or the subpackages) listed underbasePackages()
(if specified) or they will be skipped. IfincludeClasses
is empty, allProtoXyz
annotated classes that belong to the packages listed inbasePackages()
will be scanned. If neitherincludeClasses
norbasePackages()
was specified then the entire source path will be scanned. This last option should only be used in very simple demo projects.- Default:
- {}
-
-
-
excludeClasses
Class<?>[] excludeClasses
Classes to be explicitly excluded.- Default:
- {}
-
-
-
autoImportClasses
boolean autoImportClasses
Indicates if we accept classes not explicitly included byincludeClasses()
andbasePackages()
to be auto-detected by reference from the already included classes and to be added automatically. If this is set tofalse
it fails if such a case is encountered.- Default:
- false
-
-
-
service
boolean service
Enable generation of aMETA-INF/services
file for the generated class of theSerializationContextInitializer
implementation to be loadable by theServiceLoader
. This is optional and provided for convenience.- Default:
- false
-
-
-
dependsOn
Class<? extends SerializationContextInitializer>[] dependsOn
The initializers to execute before this one. List here classes or interfaces annotated withAutoProtoSchemaBuilder
from which aSerializationContextInitializer
is being generated at compile-time annotation processing.- Default:
- {}
-
-