I have the following bean:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "BankType", propOrder = {
})
public class BankType {
@XmlElement(name = "Bank_Name")
protected StringPropertyType bankName;
...
In my code I have a reference to the bankName
instance variable. I need to know the value of the name
property on @XmlElement
.
I presumed that the annotation on instance variable can be retrieved from the parent class (BankType
) by calling the getDeclaredFields().getDeclaredAnnotations()
, see https://stackoverflow.com/a/4454783/1269572).
However I don't know how to get a reference to the BankType object where the object of the instance variable I have is. Any hint please?
Or do you know other magic how to get the annotation of an instance variable?
Thanks a lot!
------------------- UPDATE 1 -------------------
I don't know the parent class (here it's BankType
) that's why I have to get it dynamically from the object of the instance variable somehow ...
I parsing a large XML and which contains lots of StringPropertyType
in different classes.