Class RequestAnnotationProcessor
java.lang.Object
javax.annotation.processing.AbstractProcessor
io.fluxzero.sdk.tracking.handling.RequestAnnotationProcessor
- All Implemented Interfaces:
Processor
@SupportedAnnotationTypes({"io.fluxzero.sdk.tracking.handling.HandleQuery","io.fluxzero.sdk.tracking.handling.HandleCommand","io.fluxzero.sdk.tracking.handling.HandleCustom"})
@AutoService(Processor.class)
public class RequestAnnotationProcessor
extends AbstractProcessor
Annotation processor that validates whether handler methods annotated with
HandleCommand, HandleQuery
or HandleCustom correctly match the response type declared by a Request payload.
The processor enforces compile-time consistency between:
- The generic type
RinRequest<R> - The actual return type of the handler method (or
Future<R>)
Validation Rules
- If a handler method accepts a
Request<R>as a parameter, its return type must matchR - Asynchronous handlers that return
Future<R>are also supported - Handlers marked as
passive=trueare skipped - Errors are reported at compile time with descriptive messages
Example
@HandleQuery
UserProfile handle(GetUser query) {
return Fluxzero.search(UserProfile.class).match(query.getUserId()).fetchFirstOrNull();
}
If the method were to return e.g. String instead of UserProfile, a compile-time error would be raised.
Supported Annotations
This processor is automatically registered via @AutoService(Processor.class) and does not require manual configuration.
-
Field Summary
Fields inherited from class AbstractProcessor
processingEnv -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanprocess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) protected voidvalidateMethod(Element method, TypeMirror requestType) protected voidvalidateReturnType(Element method, TypeMirror payloadType, TypeMirror requestType) Methods inherited from class AbstractProcessor
getCompletions, getSupportedAnnotationTypes, getSupportedOptions, init, isInitialized
-
Constructor Details
-
RequestAnnotationProcessor
public RequestAnnotationProcessor()
-
-
Method Details
-
process
- Specified by:
processin interfaceProcessor- Specified by:
processin classAbstractProcessor
-
validateMethod
-
validateReturnType
-
getSupportedSourceVersion
- Specified by:
getSupportedSourceVersionin interfaceProcessor- Overrides:
getSupportedSourceVersionin classAbstractProcessor
-