Search in sources :

Example 1 with XmlJavaTypeAdapters

use of jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapters in project jaxb-ri by eclipse-ee4j.

the class PropertyInfoImpl method getApplicableAdapter.

private XmlJavaTypeAdapter getApplicableAdapter(T type) {
    XmlJavaTypeAdapter jta = seed.readAnnotation(XmlJavaTypeAdapter.class);
    if (jta != null && isApplicable(jta, type))
        return jta;
    // check the applicable adapters on the package
    XmlJavaTypeAdapters jtas = reader().getPackageAnnotation(XmlJavaTypeAdapters.class, parent.clazz, seed);
    if (jtas != null) {
        for (XmlJavaTypeAdapter xjta : jtas.value()) {
            if (isApplicable(xjta, type))
                return xjta;
        }
    }
    jta = reader().getPackageAnnotation(XmlJavaTypeAdapter.class, parent.clazz, seed);
    if (isApplicable(jta, type))
        return jta;
    // then on the target class
    C refType = nav().asDecl(type);
    if (refType != null) {
        jta = reader().getClassAnnotation(XmlJavaTypeAdapter.class, refType, seed);
        if (// the one on the type always apply.
        jta != null && isApplicable(jta, type))
            return jta;
    }
    return null;
}
Also used : XmlJavaTypeAdapter(jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter) XmlJavaTypeAdapters(jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapters)

Example 2 with XmlJavaTypeAdapters

use of jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapters in project eclipselink by eclipse-ee4j.

the class AnnotationsProcessor method processPackageLevelAdapters.

/**
 * Process any package-level @XmlJavaTypeAdapters.
 */
private void processPackageLevelAdapters(JavaClass javaClass, TypeInfo info) {
    JavaPackage pack = javaClass.getPackage();
    if (helper.isAnnotationPresent(pack, XmlJavaTypeAdapters.class)) {
        XmlJavaTypeAdapters adapters = (XmlJavaTypeAdapters) helper.getAnnotation(pack, XmlJavaTypeAdapters.class);
        XmlJavaTypeAdapter[] adapterArray = adapters.value();
        for (XmlJavaTypeAdapter next : adapterArray) {
            processPackageLevelAdapter(next, info);
        }
    }
    if (helper.isAnnotationPresent(pack, XmlJavaTypeAdapter.class)) {
        XmlJavaTypeAdapter adapter = (XmlJavaTypeAdapter) helper.getAnnotation(pack, XmlJavaTypeAdapter.class);
        processPackageLevelAdapter(adapter, info);
    }
}
Also used : XmlJavaTypeAdapter(jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter) XmlJavaTypeAdapters(jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapters) JavaPackage(org.eclipse.persistence.jaxb.javamodel.JavaPackage)

Aggregations

XmlJavaTypeAdapter (jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter)2 XmlJavaTypeAdapters (jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapters)2 JavaPackage (org.eclipse.persistence.jaxb.javamodel.JavaPackage)1