Mega Code Archive
Gets the setters of a pojo as a map of String as key and Method as value
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.Map;
public class Util{
static final String GET = "get";
static final String IS = "is";
static final String SET = "set";
/**
* Gets the setters of a pojo as a map of {@link String} as key and
* {@link Method} as value.
*/
public static Map getSetterMethods(Class> pojoClass)
{
HashMap methods = new HashMap();
fillSetterMethods(pojoClass, methods);
return methods;
}
private static void fillSetterMethods(Class> pojoClass, Map baseMap)
{
if(pojoClass.getSuperclass()!=Object.class)
fillSetterMethods(pojoClass.getSuperclass(), baseMap);
Method[] methods = pojoClass.getDeclaredMethods();
for(int i=0; i