How do we get field name if we have field as below.
@XmlElement(required = true)
protected String code;
If i try to get as:
Field f = clazz.getDeclaredField(field);
XmlElement xmlElement = f.getAnnotation(XmlElement.class);
xmlElement.name() // returns as ##default instead of code.
default just means that the property name from the Java bean is used:
http://docs.oracle.com/javase/7/docs/api/javax/xml/bind/annotation/XmlElement.html#name%28%29
There are others posts here that deal with the same problem, none of them seems really to explain how to get the value. Here is one: Getting xml element name from unmarshalled java object with JAXB