if (!type.getPropertyMembers().containsKey(name) && !type.getReferenceMembers().containsKey(name)) {
Class<?> param = method.getParameterTypes()[0];
Type genericType = method.getGenericParameterTypes()[0];
if (isReferenceType(param, genericType)) {
type.getReferences().add(createReference(name, param));
type.getReferenceMembers().put(name, new JavaElementImpl(method, 0));
} else {
type.getProperties().add(createProperty(name, param));
type.getPropertyMembers().put(name, new JavaElementImpl(method, 0));
}
}
}
}
// second pass for protected methods with one param
for (Method method : methods) {
if (!isProtectedSetter(method)) {
continue;
}
if (method.isAnnotationPresent(Callback.class) || method.isAnnotationPresent(Context.class)) {
// Add the property name as others
others.add(toPropertyName(method.getName()));
continue;
}
Class<?> param = method.getParameterTypes()[0];
String name = toPropertyName(method.getName());
setters.add(name);
// avoid duplicate property or ref names
if (isReferenceType(param, method.getGenericParameterTypes()[0])) {
if (!type.getReferenceMembers().containsKey(name)) {
type.getReferences().add(createReference(name, param));
type.getReferenceMembers().put(name, new JavaElementImpl(method, 0));
}
} else {
if (!type.getPropertyMembers().containsKey(name)) {
type.getProperties().add(createProperty(name, param));
type.getPropertyMembers().put(name, new JavaElementImpl(method, 0));
}
}
}
// Public or protected fields unless there is a public or protected
// setter method
// for the same name
Set<Field> fields = getAllPublicAndProtectedFields(clazz, false);
for (Field field : fields) {
if (field.isAnnotationPresent(Callback.class) || field.isAnnotationPresent(Context.class)) {
continue;
}
if (setters.contains(field.getName()) || others.contains(field.getName())) {
continue;
}
String name = field.getName();
Class<?> paramType = field.getType();
if (isReferenceType(paramType, field.getGenericType())) {
if (!type.getReferenceMembers().containsKey(name)) {
type.getReferences().add(createReference(name, paramType));
type.getReferenceMembers().put(name, new JavaElementImpl(field));
}
} else {
if (!type.getPropertyMembers().containsKey(name)) {
type.getProperties().add(createProperty(name, paramType));
type.getPropertyMembers().put(name, new JavaElementImpl(field));
}
}
}
}