Java tutorial
//package com.java2s; //License from project: Apache License import java.lang.reflect.Field; import javax.xml.bind.annotation.XmlAttribute; public class Main { private static final String DEFAULT_NAME = "##default"; static String getAttributeName(Field field) { XmlAttribute attribute = (XmlAttribute) field.getAnnotation(XmlAttribute.class); return !DEFAULT_NAME.equals(attribute.name()) ? attribute.name() : field.getName(); } }