use of javax.xml.bind.annotation.XmlAttribute in project midpoint by Evolveum.
the class PrismBeanInspector method findPropertyFieldExactUncached.
private <T> Field findPropertyFieldExactUncached(Class<T> classType, String propName) {
for (Field field : classType.getDeclaredFields()) {
XmlElement xmlElement = field.getAnnotation(XmlElement.class);
if (xmlElement != null && xmlElement.name() != null && xmlElement.name().equals(propName)) {
return field;
}
XmlAttribute xmlAttribute = field.getAnnotation(XmlAttribute.class);
if (xmlAttribute != null && xmlAttribute.name() != null && xmlAttribute.name().equals(propName)) {
return field;
}
}
try {
return classType.getDeclaredField(propName);
} catch (NoSuchFieldException e) {
// nothing found
}
Class<? super T> superclass = classType.getSuperclass();
if (superclass == null || Object.class.equals(superclass)) {
return null;
}
return findPropertyField(superclass, propName);
}
use of javax.xml.bind.annotation.XmlAttribute in project swagger-core by swagger-api.
the class JAXBAnnotationsHelper method applyAttribute.
/**
* Puts definitions for XML attribute.
*
* @param member annotations provider
* @param property property instance to be updated
*/
private static void applyAttribute(AnnotatedMember member, Property property) {
final XmlAttribute attribute = member.getAnnotation(XmlAttribute.class);
if (attribute != null) {
final Xml xml = getXml(property);
xml.setAttribute(true);
setName(attribute.namespace(), attribute.name(), property);
}
}
use of javax.xml.bind.annotation.XmlAttribute in project camel by apache.
the class SpringAnnotationProcessor 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;
}
}
XmlElements elements = fieldElement.getAnnotation(XmlElements.class);
if (elements != null) {
processElements(processingEnv, roundEnv, classElement, elements, fieldElement, eipOptions, prefix);
}
XmlElementRef elementRef = fieldElement.getAnnotation(XmlElementRef.class);
if (elementRef != null) {
processElement(processingEnv, roundEnv, classElement, null, elementRef, fieldElement, eipOptions, prefix);
}
XmlElement element = fieldElement.getAnnotation(XmlElement.class);
if (element != null) {
if ("rests".equals(fieldName)) {
processRests(roundEnv, classElement, element, fieldElement, fieldName, eipOptions, prefix);
} else if ("routes".equals(fieldName)) {
processRoutes(roundEnv, classElement, element, fieldElement, fieldName, eipOptions, prefix);
} else {
processElement(processingEnv, roundEnv, classElement, element, null, fieldElement, 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.XmlAttribute 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.XmlAttribute in project camel by apache.
the class RouteDefinition method setErrorHandlerRef.
/**
* Sets the bean ref name of the error handler builder to use on this route
*/
@XmlAttribute
public void setErrorHandlerRef(String errorHandlerRef) {
this.errorHandlerRef = errorHandlerRef;
// we use an specific error handler ref (from Spring DSL) then wrap that
// with a error handler build ref so Camel knows its not just the default one
setErrorHandlerBuilder(new ErrorHandlerBuilderRef(errorHandlerRef));
}
Aggregations