Here you can find the source of isXmlElementRequired(Field f)
Parameter | Description |
---|---|
Field | f |
public static boolean isXmlElementRequired(Field f)
//package com.java2s; // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell import java.lang.reflect.Field; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementRefs; import javax.xml.bind.annotation.XmlElements; public class Main { /** Checks if the XML element filed is required. * /*from www. j ava2 s .c o m*/ * @param Field f * * @return boolean * * */ public static boolean isXmlElementRequired(Field f) { boolean ret = false; if (null != f) { XmlElement xmlElement = getXmlElement(f); if (null != xmlElement) { ret = xmlElement.required(); } else { XmlElementRefs xmlElementRefs = getXmlElementRefs(f); if (null != xmlElementRefs) { // For all "Order" and "Group" indicators (any, all, choice, sequence, group name, and group reference) // the default value for maxOccurs and minOccurs is 1. ret = true; } else { XmlElements xmlElements = getXmlElements(f); if (null != xmlElements) { // For all "Order" and "Group" indicators (any, all, choice, sequence, group name, and group reference) // the default value for maxOccurs and minOccurs is 1. ret = true; } } } } return ret; } public static XmlElement getXmlElement(Field f) { XmlElement ret = null; if (null != f) { ret = (XmlElement) f.getAnnotation(XmlElement.class); } return ret; } public static XmlElementRefs getXmlElementRefs(Field f) { XmlElementRefs ret = null; if (null != f) { ret = (XmlElementRefs) f.getAnnotation(XmlElementRefs.class); } return ret; } public static XmlElements getXmlElements(Field f) { XmlElements ret = null; if (null != f) { ret = (XmlElements) f.getAnnotation(XmlElements.class); } return ret; } }