Here you can find the source of getSetterMethods(Class> pojoClass)
public static Map<String, Method> getSetterMethods(Class<?> pojoClass)
//package com.java2s; //Licensed under the Apache License, Version 2.0 (the "License"); import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.HashMap; import java.util.Map; public class Main { static final String SET = "set"; /**/* w w w .j av a 2 s . co m*/ * Gets the setters of a pojo as a map of {@link String} as key and * {@link Method} as value. */ public static Map<String, Method> getSetterMethods(Class<?> pojoClass) { HashMap<String, Method> methods = new HashMap<String, Method>(); fillSetterMethods(pojoClass, methods); return methods; } private static void fillSetterMethods(Class<?> pojoClass, Map<String, Method> baseMap) { if (pojoClass.getSuperclass() != Object.class) fillSetterMethods(pojoClass.getSuperclass(), baseMap); Method[] methods = pojoClass.getDeclaredMethods(); for (int i = 0; i < methods.length; i++) { Method m = methods[i]; if (!Modifier.isStatic(m.getModifiers()) && m.getParameterTypes().length == 1 && m.getName().startsWith(SET) && Modifier.isPublic(m.getModifiers())) { baseMap.put(toProperty(SET.length(), m.getName()), m); } } } /** * Converts a method name into a camel-case field name, starting from {@code start}. */ public static String toProperty(int start, String methodName) { char[] prop = new char[methodName.length() - start]; methodName.getChars(start, methodName.length(), prop, 0); int firstLetter = prop[0]; prop[0] = (char) (firstLetter < 91 ? firstLetter + 32 : firstLetter); return new String(prop); } }