use of javax.xml.bind.annotation.XmlValue in project camel by apache.
the class CoreEipAnnotationProcessor method findClassProperties.
protected void findClassProperties(ProcessingEnvironment processingEnv, PrintWriter writer, RoundEnvironment roundEnv, Set<EipOption> eipOptions, TypeElement originalClassType, TypeElement classElement, String prefix, String modelName) {
while (true) {
List<VariableElement> fieldElements = ElementFilter.fieldsIn(classElement.getEnclosedElements());
for (VariableElement fieldElement : fieldElements) {
String fieldName = fieldElement.getSimpleName().toString();
XmlAttribute attribute = fieldElement.getAnnotation(XmlAttribute.class);
if (attribute != null) {
boolean skip = processAttribute(processingEnv, roundEnv, originalClassType, classElement, fieldElement, fieldName, attribute, eipOptions, prefix, modelName);
if (skip) {
continue;
}
}
XmlValue value = fieldElement.getAnnotation(XmlValue.class);
if (value != null) {
processValue(processingEnv, roundEnv, originalClassType, classElement, fieldElement, fieldName, value, eipOptions, prefix, modelName);
}
XmlElements elements = fieldElement.getAnnotation(XmlElements.class);
if (elements != null) {
processElements(processingEnv, roundEnv, classElement, elements, fieldElement, eipOptions, prefix);
}
XmlElement element = fieldElement.getAnnotation(XmlElement.class);
if (element != null) {
processElement(processingEnv, roundEnv, classElement, element, fieldElement, eipOptions, prefix);
}
// special for eips which has outputs or requires an expressions
XmlElementRef elementRef = fieldElement.getAnnotation(XmlElementRef.class);
if (elementRef != null) {
// special for routes
processRoutes(roundEnv, originalClassType, elementRef, fieldElement, fieldName, eipOptions, prefix);
// special for outputs
processOutputs(processingEnv, roundEnv, originalClassType, elementRef, fieldElement, fieldName, eipOptions, prefix);
// special for when clauses (choice eip)
processRefWhenClauses(processingEnv, roundEnv, originalClassType, elementRef, fieldElement, fieldName, eipOptions, prefix);
// special for rests (rest-dsl)
processRests(roundEnv, originalClassType, elementRef, fieldElement, fieldName, eipOptions, prefix);
// special for verbs (rest-dsl)
processVerbs(processingEnv, roundEnv, originalClassType, elementRef, fieldElement, fieldName, eipOptions, prefix);
// special for expression
processRefExpression(processingEnv, roundEnv, originalClassType, classElement, elementRef, fieldElement, fieldName, eipOptions, prefix);
}
}
// special when we process these nodes as they do not use JAXB annotations on fields, but on methods
if ("OptionalIdentifiedDefinition".equals(classElement.getSimpleName().toString())) {
processIdentified(processingEnv, roundEnv, originalClassType, classElement, eipOptions, prefix);
} else if ("RouteDefinition".equals(classElement.getSimpleName().toString())) {
processRoute(processingEnv, roundEnv, originalClassType, classElement, eipOptions, prefix);
}
// check super classes which may also have fields
TypeElement baseTypeElement = null;
TypeMirror superclass = classElement.getSuperclass();
if (superclass != null) {
String superClassName = canonicalClassName(superclass.toString());
baseTypeElement = findTypeElement(processingEnv, roundEnv, superClassName);
}
if (baseTypeElement != null) {
classElement = baseTypeElement;
} else {
break;
}
}
}
use of javax.xml.bind.annotation.XmlValue in project zm-mailbox by Zimbra.
the class JaxbInfo method processFieldRelatedAnnotations.
private void processFieldRelatedAnnotations(Annotation[] annots, String fieldName, Type defaultGenericType) {
WrappedElementInfo wrappedInfo = null;
for (Annotation annot : annots) {
if (annot instanceof XmlElementWrapper) {
XmlElementWrapper wrapper = (XmlElementWrapper) annot;
wrappedInfo = new WrappedElementInfo(wrapper, fieldName);
jaxbElemNodeInfo.add(wrappedInfo);
break;
}
}
for (Annotation annot : annots) {
if (annot instanceof XmlValue) {
elementValue = new JaxbValueInfo((XmlValue) annot, fieldName, defaultGenericType);
} else if (annot instanceof XmlAttribute) {
XmlAttribute attr = (XmlAttribute) annot;
String attrName = attr.name();
if ((attrName == null) || DEFAULT_MARKER.equals(attrName)) {
attrName = fieldName;
}
this.setXmlAttributeInfo(attr, fieldName, defaultGenericType);
this.attributeNames.add(attrName);
} else if (annot instanceof XmlElement) {
XmlElement xmlElem = (XmlElement) annot;
if (wrappedInfo == null) {
setXmlElementInfo(xmlElem, fieldName, defaultGenericType);
} else {
wrappedInfo.add(xmlElem, fieldName, defaultGenericType);
}
} else if (annot instanceof XmlElementRef) {
XmlElementRef xmlElemR = (XmlElementRef) annot;
if (wrappedInfo == null) {
setXmlElementInfo(xmlElemR, null, null);
} else {
wrappedInfo.add(xmlElemR, null, null);
}
} else if (annot instanceof XmlElements) {
JaxbPseudoNodeChoiceInfo choiceNode = new JaxbPseudoNodeChoiceInfo(fieldName, defaultGenericType);
if (wrappedInfo == null) {
jaxbElemNodeInfo.add(choiceNode);
} else {
wrappedInfo.add(choiceNode);
}
XmlElements xmlElemsAnnot = (XmlElements) annot;
for (XmlElement xmlE : xmlElemsAnnot.value()) {
choiceNode.add(xmlE);
}
} else if (annot instanceof XmlElementRefs) {
JaxbPseudoNodeChoiceInfo choiceNode = new JaxbPseudoNodeChoiceInfo(fieldName, defaultGenericType);
if (wrappedInfo == null) {
jaxbElemNodeInfo.add(choiceNode);
} else {
wrappedInfo.add(choiceNode);
}
XmlElementRefs elemRefs = (XmlElementRefs) annot;
for (XmlElementRef xmlE : elemRefs.value()) {
choiceNode.add(xmlE);
}
}
}
}
Aggregations