@Target(ElementType.TYPE)
@Retention(RetentionPolicy.SOURCE)
public @interface GenerateGetterSetters {
}
@GenerateGetterSetters
public class MyClass {
private String name;
private int age;
}
public class MyProcessor implements AnnotationProcessor {
@Override
public void process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
for (TypeElement annotation : annotations) {
for (Element element : roundEnv.getElementsAnnotatedWith(annotation)) {
if (element instanceof TypeElement) {
generateGetterSetterMethods((TypeElement) element);
}
}
}
}
private void generateGetterSetterMethods(TypeElement typeElement) {
}
}
public class MyProcessorFactory implements ProcessorFactory {
@Override
public AnnotationProcessor create() {
return new MyProcessor();
}
}
com.example.MyProcessorFactory