use of org.eclipse.persistence.jaxb.javamodel.reflection.JavaFieldImpl in project eclipselink by eclipse-ee4j.
the class AnnotationsProcessor method getFieldPropertiesForClass.
public ArrayList<Property> getFieldPropertiesForClass(JavaClass cls, TypeInfo info, boolean onlyPublic, boolean onlyExplicit) {
ArrayList<Property> properties = new ArrayList<>();
if (cls == null) {
return properties;
}
for (JavaField javaField : cls.getDeclaredFields()) {
Property property = null;
int modifiers = javaField.getModifiers();
if (!Modifier.isTransient(modifiers) && ((Modifier.isPublic(javaField.getModifiers()) && onlyPublic) || !onlyPublic || hasJAXBAnnotations(javaField))) {
if (!Modifier.isStatic(modifiers)) {
if ((onlyExplicit && hasJAXBAnnotations(javaField)) || !onlyExplicit) {
try {
property = buildNewProperty(info, cls, javaField, javaField.getName(), javaField.getResolvedType());
properties.add(property);
} catch (JAXBException ex) {
if (ex.getErrorCode() != JAXBException.INVALID_INTERFACE || !helper.isAnnotationPresent(javaField, XmlTransient.class)) {
throw ex;
}
}
}
} else {
try {
property = buildNewProperty(info, cls, javaField, javaField.getName(), javaField.getResolvedType());
if (helper.isAnnotationPresent(javaField, XmlAttribute.class)) {
Object value = ((JavaFieldImpl) javaField).get(null);
if (value != null) {
String stringValue = XMLConversionManager.getDefaultXMLManager().convertObject(value, String.class, property.getSchemaType());
property.setFixedValue(stringValue);
}
}
property.setWriteOnly(true);
if (!hasJAXBAnnotations(javaField)) {
property.setTransient(true);
}
properties.add(property);
} catch (ClassCastException e) {
// do Nothing
} catch (IllegalAccessException e) {
// do Nothing
} catch (JAXBException ex) {
if (ex.getErrorCode() != JAXBException.INVALID_INTERFACE || !helper.isAnnotationPresent(javaField, XmlTransient.class)) {
throw ex;
}
}
}
}
if (helper.isAnnotationPresent(javaField, XmlTransient.class)) {
if (property != null) {
property.setTransient(true);
}
}
}
return properties;
}
Aggregations