Here you can find the source of isXmlElementChoice(Field f, String xmlElementName)
Parameter | Description |
---|---|
Field | f |
String | xmlElementName |
public static boolean isXmlElementChoice(Field f, String xmlElementName)
//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.XmlElements; public class Main { /** Checks whether xmlElementName is applicable for the filed * //from w w w . j a va 2 s.c o m * @param Field f * @param String xmlElementName * * @return boolean indicating * * */ public static boolean isXmlElementChoice(Field f, String xmlElementName) { boolean ret = false; if (null != f && null != xmlElementName) { XmlElements xmlElements = getXmlElements(f); if (null != xmlElements && null != xmlElements.value()) { for (XmlElement xmlElement : xmlElements.value()) { if (xmlElementName.equals(xmlElement.name())) { ret = true; break; } } } } return ret; } public static XmlElements getXmlElements(Field f) { XmlElements ret = null; if (null != f) { ret = (XmlElements) f.getAnnotation(XmlElements.class); } return ret; } }