public abstract class Annotator
extends java.lang.Object
Annotator
inserts a reference to the specified annotation
to the pre-configured spots of the Java files, generated basing on Protobuf definitions.
Modifier and Type | Class and Description |
---|---|
protected class |
Annotator.TypeDeclarationAnnotation
An annotation function, that annotates the type declaration,
which is represented by
AbstractJavaSource . |
Modifier | Constructor and Description |
---|---|
protected |
Annotator(io.spine.code.java.ClassName annotation,
com.google.common.collect.ImmutableList<com.google.protobuf.Descriptors.FileDescriptor> descriptors,
java.nio.file.Path genProtoDir) |
Modifier and Type | Method and Description |
---|---|
protected void |
addAnnotation(org.jboss.forge.roaster.model.source.AnnotationTargetSource<?,?> source)
Adds a fully qualified
annotation to the AnnotationTargetSource . |
abstract void |
annotate()
Annotates the Java sources generated from Protobuf.
|
protected void |
annotate(io.spine.code.fs.java.SourceFile relativeSourcePath)
Rewrites the file applying
Annotator.TypeDeclarationAnnotation . |
protected com.google.common.collect.ImmutableList<com.google.protobuf.Descriptors.FileDescriptor> |
descriptors()
Obtains the list of file descriptors from which the annotated Java code is generated.
|
protected <T extends org.jboss.forge.roaster.model.source.JavaSource<T>> |
rewriteSource(io.spine.code.fs.java.SourceFile relativeSourcePath,
io.spine.tools.compiler.annotation.SourceVisitor<T> visitor)
Rewrites a generated Java source with the specified
relative path after applying a
SourceVisitor . |
protected Annotator(io.spine.code.java.ClassName annotation, com.google.common.collect.ImmutableList<com.google.protobuf.Descriptors.FileDescriptor> descriptors, java.nio.file.Path genProtoDir)
public abstract void annotate()
protected final void annotate(io.spine.code.fs.java.SourceFile relativeSourcePath)
Annotator.TypeDeclarationAnnotation
.protected <T extends org.jboss.forge.roaster.model.source.JavaSource<T>> void rewriteSource(io.spine.code.fs.java.SourceFile relativeSourcePath, io.spine.tools.compiler.annotation.SourceVisitor<T> visitor)
SourceVisitor
.relativeSourcePath
- the relative path to a source filevisitor
- the source visitorprotected final void addAnnotation(org.jboss.forge.roaster.model.source.AnnotationTargetSource<?,?> source)
annotation
to the AnnotationTargetSource
.
If the specified source already has the annotation
,
does nothing to avoid annotation duplication and a compilation error as a result.
source
- the program element to annotateprotected final com.google.common.collect.ImmutableList<com.google.protobuf.Descriptors.FileDescriptor> descriptors()