Search in sources :

Example 1 with XmlElementsJoinNodes

use of org.eclipse.persistence.oxm.annotations.XmlElementsJoinNodes in project eclipselink by eclipse-ee4j.

the class AnnotationsProcessor method buildChoiceProperty.

/**
 * Build a new 'choice' property. Here, we flag a new property as a 'choice'
 * and create/set an XmlModel XmlElements object based on the @XmlElements
 * annotation.
 *
 * Validation and building of the XmlElement properties will be done during
 * finalizeProperties in the processChoiceProperty method.
 */
private Property buildChoiceProperty(JavaHasAnnotations javaHasAnnotations) {
    Property choiceProperty = new Property(helper);
    choiceProperty.setChoice(true);
    boolean isIdRef = helper.isAnnotationPresent(javaHasAnnotations, XmlIDREF.class);
    choiceProperty.setIsXmlIdRef(isIdRef);
    // build an XmlElement to set on the Property
    org.eclipse.persistence.jaxb.xmlmodel.XmlElements xmlElements = new org.eclipse.persistence.jaxb.xmlmodel.XmlElements();
    XmlElement[] elements = ((XmlElements) helper.getAnnotation(javaHasAnnotations, XmlElements.class)).value();
    for (XmlElement next : elements) {
        org.eclipse.persistence.jaxb.xmlmodel.XmlElement xmlElement = new org.eclipse.persistence.jaxb.xmlmodel.XmlElement();
        xmlElement.setDefaultValue(next.defaultValue());
        xmlElement.setName(next.name());
        xmlElement.setNamespace(next.namespace());
        xmlElement.setNillable(next.nillable());
        xmlElement.setRequired(next.required());
        xmlElement.setType(next.type().getName());
        xmlElements.getXmlElement().add(xmlElement);
    }
    choiceProperty.setXmlElements(xmlElements);
    // handle XmlElementsJoinNodes
    if (helper.isAnnotationPresent(javaHasAnnotations, XmlElementsJoinNodes.class)) {
        org.eclipse.persistence.jaxb.xmlmodel.XmlJoinNodes xmlJoinNodes;
        org.eclipse.persistence.jaxb.xmlmodel.XmlJoinNodes.XmlJoinNode xmlJoinNode;
        List<org.eclipse.persistence.jaxb.xmlmodel.XmlJoinNodes> xmlJoinNodesList = new ArrayList<>();
        List<org.eclipse.persistence.jaxb.xmlmodel.XmlJoinNodes.XmlJoinNode> xmlJoinNodeList = null;
        for (XmlJoinNodes xmlJNs : ((XmlElementsJoinNodes) helper.getAnnotation(javaHasAnnotations, XmlElementsJoinNodes.class)).value()) {
            xmlJoinNodeList = new ArrayList<>();
            for (XmlJoinNode xmlJN : xmlJNs.value()) {
                xmlJoinNode = new org.eclipse.persistence.jaxb.xmlmodel.XmlJoinNodes.XmlJoinNode();
                xmlJoinNode.setXmlPath(xmlJN.xmlPath());
                xmlJoinNode.setReferencedXmlPath(xmlJN.referencedXmlPath());
                xmlJoinNodeList.add(xmlJoinNode);
            }
            if (xmlJoinNodeList.size() > 0) {
                xmlJoinNodes = new org.eclipse.persistence.jaxb.xmlmodel.XmlJoinNodes();
                xmlJoinNodes.setXmlJoinNode(xmlJoinNodeList);
                xmlJoinNodesList.add(xmlJoinNodes);
            }
        }
        choiceProperty.setXmlJoinNodesList(xmlJoinNodesList);
    }
    return choiceProperty;
}
Also used : XmlElementsJoinNodes(org.eclipse.persistence.oxm.annotations.XmlElementsJoinNodes) ArrayList(java.util.ArrayList) XmlJoinNodes(org.eclipse.persistence.oxm.annotations.XmlJoinNodes) XmlJoinNode(org.eclipse.persistence.oxm.annotations.XmlJoinNode) XmlElements(jakarta.xml.bind.annotation.XmlElements) XmlElement(jakarta.xml.bind.annotation.XmlElement) XmlProperty(org.eclipse.persistence.oxm.annotations.XmlProperty)

Aggregations

XmlElement (jakarta.xml.bind.annotation.XmlElement)1 XmlElements (jakarta.xml.bind.annotation.XmlElements)1 ArrayList (java.util.ArrayList)1 XmlElementsJoinNodes (org.eclipse.persistence.oxm.annotations.XmlElementsJoinNodes)1 XmlJoinNode (org.eclipse.persistence.oxm.annotations.XmlJoinNode)1 XmlJoinNodes (org.eclipse.persistence.oxm.annotations.XmlJoinNodes)1 XmlProperty (org.eclipse.persistence.oxm.annotations.XmlProperty)1