Java tutorial
//package com.java2s; //License from project: Apache License import javax.xml.bind.annotation.XmlRootElement; public class Main { private static final String DEFAULT_NAME = "##default"; static String getRootElementName(Class<?> clazz) { XmlRootElement element = (XmlRootElement) clazz.getAnnotation(XmlRootElement.class); return !DEFAULT_NAME.equals(element.name()) ? element.name() : clazz.getSimpleName(); } }