I'm using custom annotations in my App. I have a requirement where I need to read the value of an annotated field using reflection. For example
@CheckNull
String name;
I can have fileds declared like this. So, in some other class where I process this annotation, I need to read value of name
field,
Is it possible?
Please don't make it duplicate of this question Because, as per the accepted answer
for(Field field : cls.getDeclaredFields()){
Class type = field.getType();
String name = field.getName();
Annotation[] annotations = field.getDeclaredAnnotations();
}
It reads the type
, name
of the field and the annotations present in the field. My requirement is different. Say, if I have a field
@CheckNull
private String name;
And if someone has assinged it a value
name = "doe";
What I need to read is the value "doe". Not the annotatios, type or filed name