use of org.eclipse.persistence.oxm.annotations.XmlJoinNode in project eclipselink by eclipse-ee4j.
the class AnnotationsProcessor method processXmlJoinNodes.
/**
* Process XmlJoinNode(s) for a given Property. An
* org.eclipse.persistence.jaxb.xmlmodel.XmlJoinNode(s) will be
* created/populated using the annotation, and set on the Property for later
* processing.
*
* It is assumed that for a single join node XmlJoinNode will be used, and
* for multiple join nodes XmlJoinNodes will be used.
*
* @param property
* Property that may contain @XmlJoinNodes/@XmlJoinNode
*/
private void processXmlJoinNodes(Property property) {
List<org.eclipse.persistence.jaxb.xmlmodel.XmlJoinNodes.XmlJoinNode> xmlJoinNodeList;
org.eclipse.persistence.jaxb.xmlmodel.XmlJoinNodes.XmlJoinNode xmlJoinNode;
org.eclipse.persistence.jaxb.xmlmodel.XmlJoinNodes xmlJoinNodes;
// handle XmlJoinNodes
if (helper.isAnnotationPresent(property.getElement(), XmlJoinNodes.class)) {
xmlJoinNodeList = new ArrayList<>();
for (XmlJoinNode xmlJN : ((XmlJoinNodes) helper.getAnnotation(property.getElement(), XmlJoinNodes.class)).value()) {
xmlJoinNode = new org.eclipse.persistence.jaxb.xmlmodel.XmlJoinNodes.XmlJoinNode();
xmlJoinNode.setXmlPath(xmlJN.xmlPath());
xmlJoinNode.setReferencedXmlPath(xmlJN.referencedXmlPath());
xmlJoinNodeList.add(xmlJoinNode);
}
xmlJoinNodes = new org.eclipse.persistence.jaxb.xmlmodel.XmlJoinNodes();
xmlJoinNodes.setXmlJoinNode(xmlJoinNodeList);
property.setXmlJoinNodes(xmlJoinNodes);
} else // handle XmlJoinNode
if (helper.isAnnotationPresent(property.getElement(), XmlJoinNode.class)) {
XmlJoinNode xmlJN = (XmlJoinNode) helper.getAnnotation(property.getElement(), XmlJoinNode.class);
xmlJoinNode = new org.eclipse.persistence.jaxb.xmlmodel.XmlJoinNodes.XmlJoinNode();
xmlJoinNode.setXmlPath(xmlJN.xmlPath());
xmlJoinNode.setReferencedXmlPath(xmlJN.referencedXmlPath());
xmlJoinNodeList = new ArrayList<>();
xmlJoinNodeList.add(xmlJoinNode);
xmlJoinNodes = new org.eclipse.persistence.jaxb.xmlmodel.XmlJoinNodes();
xmlJoinNodes.setXmlJoinNode(xmlJoinNodeList);
property.setXmlJoinNodes(xmlJoinNodes);
}
}
use of org.eclipse.persistence.oxm.annotations.XmlJoinNode 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