Search in sources :

Example 1 with XmlElementDecl

use of javax.xml.bind.annotation.XmlElementDecl in project camel by apache.

the class JaxbHelper method getJaxbElementFactoryMethod.

public static <T> Method getJaxbElementFactoryMethod(CamelContext camelContext, Class<T> type) {
    if (camelContext == null) {
        return null;
    }
    // find the first method that has @XmlElementDecl with one parameter that matches the type
    Class factory = getObjectFactory(camelContext, type);
    if (factory != null) {
        for (Method m : factory.getMethods()) {
            final XmlElementDecl a = m.getAnnotation(XmlElementDecl.class);
            if (a == null) {
                continue;
            }
            final Class<?>[] parameters = m.getParameterTypes();
            if (parameters.length == 1 && parameters[0].isAssignableFrom(type)) {
                return m;
            }
        }
    }
    return null;
}
Also used : XmlElementDecl(javax.xml.bind.annotation.XmlElementDecl) Method(java.lang.reflect.Method)

Example 2 with XmlElementDecl

use of javax.xml.bind.annotation.XmlElementDecl in project midpoint by Evolveum.

the class PrismBeanInspector method lookupSubstitutionUncached.

private Field lookupSubstitutionUncached(Class beanClass, Method elementMethodInObjectFactory) {
    XmlElementDecl xmlElementDecl = elementMethodInObjectFactory.getAnnotation(XmlElementDecl.class);
    if (xmlElementDecl == null) {
        return null;
    }
    final String substitutionHeadName = xmlElementDecl.substitutionHeadName();
    return findField(beanClass, field -> {
        XmlElementRef xmlElementRef = field.getAnnotation(XmlElementRef.class);
        return xmlElementRef != null && xmlElementRef.name().equals(substitutionHeadName);
    });
}
Also used : XmlElementRef(javax.xml.bind.annotation.XmlElementRef) XmlElementDecl(javax.xml.bind.annotation.XmlElementDecl)

Aggregations

XmlElementDecl (javax.xml.bind.annotation.XmlElementDecl)2 Method (java.lang.reflect.Method)1 XmlElementRef (javax.xml.bind.annotation.XmlElementRef)1