It appears that PODAM only discovers setters if they return void. However all of my objects in my projects are written with fluency for the extreme convenience it gets to chain sets together and avoid numerous constructors.
public class MyClass {
private String myVariable;
public String getMyVariable() { return myVariable; }
public MyClass setMyVariable( String myVariable ) { this.myVariable = myVariable; return this; }
}
However in the PODAM code, it explicitly short circuits this:
public static Set<Method> getPojoSetters(Class<?> clazz, Set<String> classFields) {
Set<Method> classSetters = new HashSet<Method>();
while (clazz != null) {
Method[] declaredMethods = clazz.getDeclaredMethods();
String candidateField = null;
for (Method method : declaredMethods) {
if (!method.getName().startsWith("set")) {
continue;
}
if (!method.getReturnType().equals(void.class)) {
continue;
}
candidateField = extractFieldNameFromSetterMethod(method);
if (!classFields.contains(candidateField)) {
continue;
}
classSetters.add(method);
}
clazz = clazz.getSuperclass();
}
return classSetters;
}I understand it goes against bean convention, and the default behavior should not be changed. However would folks be open to making this and optional setting when calling manufacturePojo or when creating a factory? I can contribute the changes pretty easily.
Thanks,
Ryan