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