HashMap setters = new HashMap();
if (methods.isEmpty() == false)
{
for (Iterator i = methods.iterator(); i.hasNext();)
{
MethodInfo methodInfo = (MethodInfo) i.next();
if (methodInfo.isPublic() && methodInfo.isStatic() == false)
{
String name = methodInfo.getName();
String upperName = getUpperPropertyName(name);
if (isGetter(methodInfo))
{
getters.put(upperName, methodInfo);
}
else if (isSetter(methodInfo))
{
ArrayList list = (ArrayList) setters.get(upperName);
if (list == null)
{
list = new ArrayList();
setters.put(upperName, list);
}
list.add(methodInfo);
}
}
}
}
HashSet properties = new HashSet();
if (getters.isEmpty() == false)
{
for (Iterator i = getters.entrySet().iterator(); i.hasNext();)
{
Map.Entry entry = (Map.Entry) i.next();
String name = (String) entry.getKey();
MethodInfo getter = (MethodInfo) entry.getValue();
MethodInfo setter = null;
ArrayList setterList = (ArrayList) setters.remove(name);
if (setterList != null && setterList.size() != 0)
{
for (int j = 0; j < setterList.size(); ++j)
{
MethodInfo thisSetter = (MethodInfo) setterList.get(j);
TypeInfo pinfo = thisSetter.getParameterTypes()[0];
if (getter.getReturnType().equals(pinfo) == true)
{
setter = thisSetter;
break;
}
}
}
String lowerName = getLowerPropertyName(name);
properties.add(new AbstractPropertyInfo(lowerName, name, getter.getReturnType(), getter, setter));
}
}
if (setters.isEmpty() == false)
{
for (Iterator i = setters.entrySet().iterator(); i.hasNext();)
{
Map.Entry entry = (Map.Entry) i.next();
String name = (String) entry.getKey();
ArrayList setterList = (ArrayList) entry.getValue();
// Review: Maybe should just create duplicate propertyInfo and let the configurator guess?
if (setterList.size() == 1)
{
MethodInfo setter = (MethodInfo) setterList.get(0);
TypeInfo pinfo = setter.getParameterTypes()[0];
String lowerName = getLowerPropertyName(name);
properties.add(new AbstractPropertyInfo(lowerName, name, pinfo, null, setter));
}
}
}