use of org.eclipse.persistence.jaxb.xmlmodel.XmlAccessType in project eclipselink by eclipse-ee4j.
the class AnnotationsProcessor method preProcessXmlAccessorType.
/**
* Process @XmlAccessorType annotation on a given JavaClass and update the
* TypeInfo for pre-processing.
*/
private void preProcessXmlAccessorType(JavaClass javaClass, TypeInfo info, NamespaceInfo packageNamespace) {
org.eclipse.persistence.jaxb.xmlmodel.XmlAccessType xmlAccessType;
if (javaClass.getDeclaredAnnotation(helper.getJavaClass(XmlAccessorType.class)) != null) {
XmlAccessorType accessorType = (XmlAccessorType) helper.getAnnotation(javaClass, XmlAccessorType.class);
xmlAccessType = org.eclipse.persistence.jaxb.xmlmodel.XmlAccessType.fromValue(accessorType.value().name());
info.setXmlAccessType(xmlAccessType);
}
}
use of org.eclipse.persistence.jaxb.xmlmodel.XmlAccessType in project eclipselink by eclipse-ee4j.
the class XMLProcessor method createProperty.
private Property createProperty(TypeInfo info, JavaAttribute javaAttribute) {
XmlAccessType xmlAccessorType = javaAttribute.getXmlAccessorType();
// Property prop = new Property();
// prop.setPropertyName(javaAttribute.getJavaAttribute());
String propName = javaAttribute.getJavaAttribute();
JavaHasAnnotations element = null;
JavaClass pType = null;
JavaClass jClass = this.jModelInput.getJavaModel().getClass(info.getJavaClassName());
if (xmlAccessorType == XmlAccessType.PROPERTY) {
// set up accessor method names
String name = Character.toUpperCase(propName.charAt(0)) + propName.substring(1);
String getMethodName = GET_STR + name;
String setMethodName = SET_STR + name;
JavaMethod jMethod = jClass.getDeclaredMethod(getMethodName, new JavaClass[] {});
if (jMethod == null) {
getMethodName = IS_STR + name;
jMethod = jClass.getDeclaredMethod(getMethodName, new JavaClass[] {});
}
if (jMethod != null) {
pType = jMethod.getReturnType();
element = jMethod;
} else {
// look for a set method if type is set on javaAttribute
for (Object next : jClass.getDeclaredMethods()) {
JavaMethod nextMethod = (JavaMethod) next;
if (nextMethod.getName().equals(setMethodName) && nextMethod.getParameterTypes().length == 1) {
pType = nextMethod.getParameterTypes()[0];
element = nextMethod;
}
}
if (element == null) {
return null;
}
}
} else {
JavaField jField = jClass.getDeclaredField(propName);
if (jField == null) {
return null;
}
pType = jField.getResolvedType();
element = jField;
}
return this.aProcessor.buildNewProperty(info, jClass, element, propName, pType);
}
Aggregations