use of javax.xml.bind.annotation.XmlType in project zm-mailbox by Zimbra.
the class JaxbInfo method gatherInfo.
private void gatherInfo() {
XmlAccessorType accessorType;
rootElementName = null;
XmlAccessType accessType = null;
XmlRootElement rootE = jaxbClass.getAnnotation(XmlRootElement.class);
if (rootE != null) {
rootElementName = rootE.name();
}
xmlType = jaxbClass.getAnnotation(XmlType.class);
accessorType = jaxbClass.getAnnotation(XmlAccessorType.class);
if (accessorType == null) {
Package pkg = jaxbClass.getPackage();
accessorType = pkg.getAnnotation(XmlAccessorType.class);
}
if (accessorType != null) {
accessType = accessorType.value();
}
if (accessType == null) {
// Default value for JAXB
accessType = XmlAccessType.PUBLIC_MEMBER;
}
Field[] fields = jaxbClass.getDeclaredFields();
for (Field field : fields) {
XmlTransient xmlTransient = field.getAnnotation(XmlTransient.class);
if (xmlTransient != null) {
continue;
}
Annotation[] fAnnots = field.getAnnotations();
if ((fAnnots == null) || (fAnnots.length == 0)) {
boolean autoFields = (accessType.equals(XmlAccessType.PUBLIC_MEMBER) || accessType.equals(XmlAccessType.FIELD));
if (!autoFields) {
continue;
}
}
processFieldRelatedAnnotations(fAnnots, field.getName(), field.getGenericType());
}
Method[] methods = jaxbClass.getDeclaredMethods();
for (Method method : methods) {
XmlTransient xmlTransient = method.getAnnotation(XmlTransient.class);
if (xmlTransient != null) {
continue;
}
if (!isGetterOrSetter(method)) {
continue;
}
Annotation[] mAnnots = method.getAnnotations();
if ((mAnnots == null) || (mAnnots.length == 0)) {
boolean autoGettersSetters = (accessType.equals(XmlAccessType.PUBLIC_MEMBER) || accessType.equals(XmlAccessType.PROPERTY));
if (!autoGettersSetters) {
continue;
}
}
processFieldRelatedAnnotations(mAnnots, guessFieldNameFromGetterOrSetter(method.getName()), method.getGenericReturnType());
}
}
Aggregations