Here you can find the source of getSetter(Class> clazz, Field field)
public static Method getSetter(Class<?> clazz, Field field) throws SecurityException, NoSuchMethodException
//package com.java2s; //License from project: Apache License import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.Locale; public class Main { public static Method getSetter(Object object, Field field) throws SecurityException, NoSuchMethodException { return getSetter(object.getClass(), field); }//from w w w. j a va 2 s . c om public static Method getSetter(Class<?> clazz, Field field) throws SecurityException, NoSuchMethodException { Method setter = clazz.getMethod(getSetterName(field), field.getType()); if (!setter.getReturnType().equals(void.class)) { throw new NoSuchMethodException(); } return setter; } public static String getSetterName(Field field) { String name = field.getName(); return "set" + name.substring(0, 1).toUpperCase(Locale.US) + name.substring(1); } }