Class MessageProcessor
java.lang.Object
javax.annotation.processing.AbstractProcessor
pt.unl.fct.di.novasys.babel2.channels.MessageProcessor
- All Implemented Interfaces:
Processor
@SupportedAnnotationTypes("pt.unl.fct.di.novasys.babel2.channels.BabelIPMessage")
@SupportedSourceVersion(RELEASE_17)
@AutoService(Processor.class)
public class MessageProcessor
extends AbstractProcessor
Compile-time annotation processor that generates binary serializer classes
for every Java
record annotated with BabelIPMessage.
For each annotated type the processor introspects the record's component
accessor methods
and emits a new class <RecordName>Serializer in the
pt.unl.fct.di.novasys.babel2.channels.serializers package. The
generated class:
- implements
BabelNetworkMessageSerializer; - is annotated with
@AutoService(BabelNetworkMessageSerializer.class)so that it is automatically registered in theSerializerRegistryvia the JavaServiceLoader; - supports the following component types: all Java primitives and their
boxed equivalents,
String,UUID,IPBabelNodeComponent, arrays, and parameterizedCollection/Mapimplementations.
The processor runs at SourceVersion.RELEASE_17 and targets the
annotation type
pt.unl.fct.di.novasys.babel2.channels.BabelIPMessage. It uses
JavaPoet to construct the
source files that
are written via the standard Filer.
A compile-time error is reported (via
Diagnostic.Kind.ERROR) if:
- the annotated type is not a
record; - a collection or map component lacks generic type arguments;
- an unsupported type is encountered.
-
Field Summary
Fields inherited from class AbstractProcessor
processingEnv -
Constructor Summary
ConstructorsConstructorDescriptionDefault public constructor invoked by the Java annotation processing framework. -
Method Summary
Modifier and TypeMethodDescriptionvoidinit(ProcessingEnvironment processingEnv) booleanprocess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) Methods inherited from class AbstractProcessor
getCompletions, getSupportedAnnotationTypes, getSupportedOptions, getSupportedSourceVersion, isInitialized
-
Constructor Details
-
MessageProcessor
public MessageProcessor()Default public constructor invoked by the Java annotation processing framework.
-
-
Method Details
-
process
- Specified by:
processin interfaceProcessor- Specified by:
processin classAbstractProcessor
-
init
- Specified by:
initin interfaceProcessor- Overrides:
initin classAbstractProcessor
-