Package org.instancio.spi
Annotation Type InstancioServiceProvider.AnnotationProcessor.AnnotationHandler
- Enclosing interface:
InstancioServiceProvider.AnnotationProcessor
@ExperimentalApi
@Target(METHOD)
@Retention(RUNTIME)
public static @interface InstancioServiceProvider.AnnotationProcessor.AnnotationHandler
Denotes a method for handling annotations.
The accepted signatures for @AnnotationHandler
methods are:
void example(Annotation annotation, GeneratorSpec<?> spec, Node node)
void example(Annotation annotation, GeneratorSpec<?> spec)
where:
- the
annotation
andspec
parameters can be subtypes ofAnnotation
andGeneratorSpec
, respectively - the
node
parameter is optional, and can be omitted if it's not needed
Example:
@Retention(RetentionPolicy.RUNTIME)
public @interface HexString {
int length();
}
public class SampleAnnotationProcessor implements AnnotationProcessor {
@AnnotationHandler
void handleZipCode(HexString annotation, StringGeneratorSpec spec) {
spec.hex().length(annotation.length());
}
}
- Since:
- 4.5.0