I have a small use case. Consider a class-
@Myannotation
class Abc {
String pqr;
String lmn;
static List<String> xyz;
}
xyz
will have ["pqr", "lmn",..]
.
I want to create custom annotation for class Abc to initialize list xyz with other variables' names like "pqr".
So there are 2 sub problems here -
- a. Creating Custom annotation for class.- (I got a little idea about it from the online articles on how to create. But a little unsure on how to do the processing of the annotation.)
Should start something like
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.Type)
public @interface Myannotation {
}
- b. How to get variable names of the class? - (Is that even possible for same class?)
Can I do that? If yes, How can I do that?