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