Here you can find the source of getSetter(final Class> clazz, final String fieldName, final Class>... fieldClass)
public static Method getSetter(final Class<?> clazz, final String fieldName, final Class<?>... fieldClass)
//package com.java2s; //License from project: Apache License import java.lang.reflect.Method; public class Main { public static Method getSetter(final Class<?> clazz, final String fieldName, final Class<?>... fieldClass) { final String methodName = "set" + capitalize(fieldName); // private / protected method try {//from ww w .j a va 2s . com final Method method = clazz.getDeclaredMethod(methodName, fieldClass); method.setAccessible(true); return method; } catch (SecurityException | NoSuchMethodException e) { } return null; } public static String capitalize(final String str) { final int strLen; if (str == null || (strLen = str.length()) == 0) { return str; } return new StringBuilder(strLen).append(String.valueOf(str.charAt(0)).toUpperCase()) .append(str.substring(1)).toString(); } }