D
- the proto descriptor type used to receive option
valuepublic abstract class OptionAnnotator<D extends com.google.protobuf.Descriptors.GenericDescriptor> extends Annotator
Annotator
which annotates Java sources basing on a given Protobuf option.
Subtypes are purposed for different Protobuf option types such as FileOptions
,
MessageOptions
etc.
Depending on the option type, an annotator manages a corresponding Protobuf descriptor
(e.g. FileDescriptorProto
for FileOptions
).
Annotator.TypeDeclarationAnnotation
Modifier | Constructor and Description |
---|---|
protected |
OptionAnnotator(io.spine.code.java.ClassName annotation,
ApiOption option,
com.google.common.collect.ImmutableList<com.google.protobuf.Descriptors.FileDescriptor> fileDescriptors,
java.nio.file.Path genProtoDir) |
Modifier and Type | Method and Description |
---|---|
protected void |
annotate(com.google.protobuf.Descriptors.FileDescriptor fileDescriptor)
Annotates the Java sources generated from the specified file descriptor.
|
protected void |
annotateMessageTypes(com.google.protobuf.Descriptors.Descriptor type,
com.google.protobuf.Descriptors.FileDescriptor file)
Annotates message class and MessageOrBuilder interface that correspond to the passed type.
|
protected abstract void |
annotateMultipleFiles(com.google.protobuf.Descriptors.FileDescriptor fileDescriptor)
Annotates the Java sources generated from the specified file descriptor
if
java_multiple_files proto file option is true . |
protected abstract void |
annotateOneFile(com.google.protobuf.Descriptors.FileDescriptor fileDescriptor)
Annotates the Java sources generated from the specified file descriptor
if
java_multiple_files proto file option is set to false . |
protected ApiOption |
option()
Obtains the Protobuf API option to transform into a Java annotation.
|
protected abstract boolean |
shouldAnnotate(D descriptor)
Tells whether the generated program elements
from the specified descriptor should be annotated.
|
addAnnotation, annotate, annotate, descriptors, rewriteSource
protected OptionAnnotator(io.spine.code.java.ClassName annotation, ApiOption option, com.google.common.collect.ImmutableList<com.google.protobuf.Descriptors.FileDescriptor> fileDescriptors, java.nio.file.Path genProtoDir)
protected final void annotate(com.google.protobuf.Descriptors.FileDescriptor fileDescriptor)
protected abstract void annotateOneFile(com.google.protobuf.Descriptors.FileDescriptor fileDescriptor)
java_multiple_files
proto file option is set to false
.fileDescriptor
- the file descriptorprotected abstract void annotateMultipleFiles(com.google.protobuf.Descriptors.FileDescriptor fileDescriptor)
java_multiple_files
proto file option is true
.fileDescriptor
- the file descriptorprotected abstract boolean shouldAnnotate(D descriptor)
descriptor
- the descriptor to extract option
value.true
if generated element should be annotated, false
otherwiseprotected final ApiOption option()
protected final void annotateMessageTypes(com.google.protobuf.Descriptors.Descriptor type, com.google.protobuf.Descriptors.FileDescriptor file)