I am writing an annotation processor in android which generates a java file. I am using JavaPoet
library for that.
The purpose of generated file: It should have a list of names of the classes with a particular annotation that my processor supports and provide a public method to get that list.
Now, I've generated the file:
private final List<String> names;
GeneratedFile(ArrayList<String> names) {
this.names = names;
}
public List<String> getNames() {
return names;
}
Now, the problem is: How do I initialize the names
field from the processor? The Javapoet
api provides an initializer
for the field but that only takes a string.
In my processor, I've the list of classes that have my supported annotation. I want to populate this field with that list.