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;
}
Aggregations