Java Reflection Field Set setFieldBySomeMethod(List setMethods, Object object, Object value)

Here you can find the source of setFieldBySomeMethod(List setMethods, Object object, Object value)

Description

set Field By Some Method

License

Open Source License

Declaration

private static void setFieldBySomeMethod(List<Method> setMethods, Object object, Object value)
        throws Exception 

Method Source Code

//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;
    }
}

Related

  1. setField(String name, Object target, Object value)
  2. setField(String name, Object target, Object value)
  3. setField(T object, Field field, ResourceBundle bundle)
  4. setFieldAccessible(Class clazz, String... names)
  5. setFieldAccessible(Field field)
  6. setFieldContent(final Object obj, final String name, final Object value)
  7. setFieldEditable(Class clazz, String fieldName)
  8. setFieldForAnnotation(Object target, Class annotation, Object value)
  9. setFieldHelper(Object o, String name, Object v)