Here you can find the source of setFieldBySomeMethod(List
private static void setFieldBySomeMethod(List<Method> setMethods, Object object, Object value) throws Exception
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Method; import java.util.List; public class Main { private static void setFieldBySomeMethod(List<Method> setMethods, Object object, Object value) throws Exception { Object t = getFieldBySomeMethod(setMethods, object); setMethods.get(setMethods.size() - 1).invoke(t, value); }/* www.ja va2 s .c o m*/ private static Object getFieldBySomeMethod(List<Method> list, Object t) throws Exception { Method m; for (int i = 0; i < list.size() - 1; i++) { m = list.get(i); t = m.invoke(t, new Object[] {}); } return t; } }