Java examples for XML:JAXB
Find the xml element metadata for a specified JAXB property.
//package com.java2s; import javax.xml.bind.annotation.XmlElement; import java.beans.PropertyDescriptor; public class Main { /**//from www. j a v a 2 s . c o m * Find the xml element metadata for a specified JAXB property. * * @param property The JAXB property for which to find the xml element metadata. * @return The xml element metadata, or null if none found. */ public static XmlElement findXmlElement(PropertyDescriptor property) { XmlElement xmlElement = null; if (property.getReadMethod() != null) { xmlElement = property.getReadMethod().getAnnotation( XmlElement.class); } if ((xmlElement == null) && (property.getWriteMethod() != null)) { xmlElement = property.getWriteMethod().getAnnotation( XmlElement.class); } return xmlElement; } }