Search in sources :

Example 1 with XmlDiscriminatorNode

use of org.eclipse.persistence.oxm.annotations.XmlDiscriminatorNode in project eclipselink by eclipse-ee4j.

the class AnnotationsProcessor method preBuildTypeInfo.

/**
 * Process class level annotations only. It is assumed that a call to init()
 * has been made prior to calling this method. After the types created via
 * this method have been modified (if necessary) postBuildTypeInfo and
 * processJavaClasses should be called to finish processing.
 */
public Map<String, TypeInfo> preBuildTypeInfo(JavaClass[] javaClasses) {
    for (JavaClass javaClass : javaClasses) {
        String qualifiedName = javaClass.getQualifiedName();
        TypeInfo info = typeInfos.get(qualifiedName);
        if (javaClass.isArray() || (info != null && info.isPreBuilt()) || !shouldGenerateTypeInfo(javaClass) || isXmlRegistry(javaClass)) {
            continue;
        }
        if (javaClass.isEnum()) {
            info = new EnumTypeInfo(helper, javaClass);
        } else {
            info = new TypeInfo(helper, javaClass);
        }
        info.setJavaClassName(qualifiedName);
        info.setPreBuilt(true);
        // handle @XmlTransient
        if (helper.isAnnotationPresent(javaClass, XmlTransient.class)) {
            info.setXmlTransient(true);
        }
        // handle @XmlElementNillable
        processXmlElementNillable(javaClass, info);
        // handle @XmlExtensible
        processXmlExtensible(javaClass, info);
        // handle @XmlInlineBinaryData
        if (helper.isAnnotationPresent(javaClass, XmlInlineBinaryData.class)) {
            info.setInlineBinaryData(true);
        }
        // handle @NamedObjectGraph
        processNamedObjectGraphs(javaClass, info);
        // handle @XmlRootElement
        processXmlRootElement(javaClass, info);
        // handle @XmlSeeAlso
        processXmlSeeAlso(javaClass, info);
        PackageInfo packageInfo = getPackageInfoForPackage(javaClass);
        if (packageInfo != null && packageInfo.getPackageLevelAdaptersByClass().size() > 0) {
            for (String adapterClass : packageInfo.getPackageLevelAdaptersByClass().keySet()) {
                JavaClass boundType = packageInfo.getPackageLevelAdaptersByClass().get(adapterClass);
                info.getPackageLevelAdaptersByClass().put(adapterClass, boundType);
            }
        }
        NamespaceInfo namespaceInfo = packageInfo.getNamespaceInfo();
        // handle @XmlType
        preProcessXmlType(javaClass, info, namespaceInfo);
        // handle @XmlAccessorType
        preProcessXmlAccessorType(javaClass, info, namespaceInfo);
        // handle @XmlAccessorOrder
        preProcessXmlAccessorOrder(javaClass, info, namespaceInfo);
        // handle package level @XmlJavaTypeAdapters
        processPackageLevelAdapters(javaClass, info);
        // handle Accessor Factory
        processAccessorFactory(javaClass, info);
        // handle class level @XmlJavaTypeAdapters
        processClassLevelAdapters(javaClass, info);
        // handle descriptor customizer
        preProcessCustomizer(javaClass, info);
        // handle package level @XmlSchemaType(s)
        processSchemaTypes(javaClass, info);
        // handle class extractor
        if (helper.isAnnotationPresent(javaClass, XmlClassExtractor.class)) {
            XmlClassExtractor classExtractor = (XmlClassExtractor) helper.getAnnotation(javaClass, XmlClassExtractor.class);
            info.setClassExtractorName(classExtractor.value().getName());
        }
        // handle user properties
        if (helper.isAnnotationPresent(javaClass, XmlProperties.class)) {
            XmlProperties xmlProperties = (XmlProperties) helper.getAnnotation(javaClass, XmlProperties.class);
            Map<Object, Object> propertiesMap = createUserPropertiesMap(xmlProperties.value());
            info.setUserProperties(propertiesMap);
        } else if (helper.isAnnotationPresent(javaClass, XmlProperty.class)) {
            XmlProperty xmlProperty = (XmlProperty) helper.getAnnotation(javaClass, XmlProperty.class);
            Map<Object, Object> propertiesMap = createUserPropertiesMap(new XmlProperty[] { xmlProperty });
            info.setUserProperties(propertiesMap);
        }
        // handle class indicator field name
        if (helper.isAnnotationPresent(javaClass, XmlDiscriminatorNode.class)) {
            XmlDiscriminatorNode xmlDiscriminatorNode = (XmlDiscriminatorNode) helper.getAnnotation(javaClass, XmlDiscriminatorNode.class);
            info.setXmlDiscriminatorNode(xmlDiscriminatorNode.value());
        }
        // handle class indicator
        if (helper.isAnnotationPresent(javaClass, XmlDiscriminatorValue.class)) {
            XmlDiscriminatorValue xmlDiscriminatorValue = (XmlDiscriminatorValue) helper.getAnnotation(javaClass, XmlDiscriminatorValue.class);
            info.setXmlDiscriminatorValue(xmlDiscriminatorValue.value());
        }
        typeInfoClasses.add(javaClass);
        typeInfos.put(info.getJavaClassName(), info);
    }
    return typeInfos;
}
Also used : XmlProperties(org.eclipse.persistence.oxm.annotations.XmlProperties) XmlProperty(org.eclipse.persistence.oxm.annotations.XmlProperty) XmlDiscriminatorValue(org.eclipse.persistence.oxm.annotations.XmlDiscriminatorValue) XmlClassExtractor(org.eclipse.persistence.oxm.annotations.XmlClassExtractor) JavaClass(org.eclipse.persistence.jaxb.javamodel.JavaClass) Map(java.util.Map) HashMap(java.util.HashMap) XmlDiscriminatorNode(org.eclipse.persistence.oxm.annotations.XmlDiscriminatorNode)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 JavaClass (org.eclipse.persistence.jaxb.javamodel.JavaClass)1 XmlClassExtractor (org.eclipse.persistence.oxm.annotations.XmlClassExtractor)1 XmlDiscriminatorNode (org.eclipse.persistence.oxm.annotations.XmlDiscriminatorNode)1 XmlDiscriminatorValue (org.eclipse.persistence.oxm.annotations.XmlDiscriminatorValue)1 XmlProperties (org.eclipse.persistence.oxm.annotations.XmlProperties)1 XmlProperty (org.eclipse.persistence.oxm.annotations.XmlProperty)1