// map of raw field names to translated names, translated names may be different
// due to annotations like XMLElement
Map<String, String> rawToTranslatedFields = new HashMap<String, String>();
NameBasedTranslator nameTranslator = new NameBasedTranslator(this.options);
for (ClassDoc classDoc : classes) {
AnnotationParser p = new AnnotationParser(classDoc);
String xmlAccessorType = p.getAnnotationValue("javax.xml.bind.annotation.XmlAccessorType", "value");
Set<String> customizedFieldNames = new HashSet<String>();
// add fields
Set<String> excludeFields = new HashSet<String>();
if (!"javax.xml.bind.annotation.XmlAccessType.PROPERTY".equals(xmlAccessorType)) {
FieldDoc[] fieldDocs = classDoc.fields();
if (fieldDocs != null) {
for (FieldDoc field : fieldDocs) {
// ignore static or transient fields or _ prefixed ones
if (field.isStatic() || field.isTransient() || field.name().charAt(0) == '_') {
continue;
}
String name = this.translator.fieldName(field).value();
rawToTranslatedFields.put(field.name(), name);
if (!field.name().equals(name)) {
customizedFieldNames.add(field.name());
}
// ignore deprecated fields
if (this.options.isExcludeDeprecatedFields() && ParserHelper.isDeprecated(field)) {
excludeFields.add(field.name());
continue;
}
// ignore fields we are to explicitly exclude
if (ParserHelper.hasTag(field, this.options.getExcludeFieldTags())) {
excludeFields.add(field.name());
continue;
}
// ignore fields that are for a different json view
ClassDoc[] jsonViews = ParserHelper.getJsonViews(field);
if (!ParserHelper.isItemPartOfView(this.viewClasses, jsonViews)) {
excludeFields.add(field.name());
continue;
}
if (name != null && !elements.containsKey(name)) {
Type fieldType = getModelType(field.type(), nested);
String description = getFieldDescription(field, true);
String min = getFieldMin(field);
String max = getFieldMax(field);
Boolean required = getFieldRequired(field);
String defaultValue = getFieldDefaultValue(field);
String paramCategory = this.composite ? ParserHelper.paramTypeOf(false, this.consumesMultipart, field, fieldType, this.options)
: null;
elements.put(field.name(), new TypeRef(field.name(), paramCategory, " field: " + field.name(), fieldType, description, min, max,
defaultValue, required));
}
}
}
}
// add methods
if (!"javax.xml.bind.annotation.XmlAccessType.FIELD".equals(xmlAccessorType)) {
MethodDoc[] methodDocs = classDoc.methods();
if (methodDocs != null) {
for (MethodDoc method : methodDocs) {
// ignore static methods and private methods
if (method.isStatic() || method.isPrivate() || method.name().charAt(0) == '_') {
continue;
}
// we tie getters and their corresponding methods together via this rawFieldName
String rawFieldName = nameTranslator.methodName(method).value();
String translatedNameViaMethod = this.translator.methodName(method).value();
if (translatedNameViaMethod != null) {