Here you can find the source of invokeSetter(Object target, Class clazz, String methodName, String getterMethod, Object param)
public static void invokeSetter(Object target, Class clazz, String methodName, String getterMethod, Object param) throws Exception
//package com.java2s; //License from project: Apache License import java.lang.reflect.Method; public class Main { public static void invokeSetter(Object target, Class clazz, String methodName, String getterMethod, Object param) throws Exception { Method getter = clazz.getMethod(getterMethod, (Class[]) null); Method setter = clazz.getMethod(methodName, new Class[] { getter.getReturnType() }); setter.invoke(target, param);//from ww w.ja v a 2s. co m } }