Java Reflection Method Getter Invoke invokeSetter(Object target, Class clazz, String methodName, String getterMethod, Object param)

Here you can find the source of invokeSetter(Object target, Class clazz, String methodName, String getterMethod, Object param)

Description

invoke Setter

License

Apache License

Declaration

public static void invokeSetter(Object target, Class clazz, String methodName, String getterMethod,
            Object param) throws Exception 

Method Source Code


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

Related

  1. invokeGetter(Object obj, String methodName, int defaultValue)
  2. invokeGetter(Object object, String field)
  3. invokeGetter(Object target, Method getter)
  4. invokeGetterMethod(final Method method, final Object object)
  5. invokeGetterSafe(Object o, String name, boolean forceAccess)
  6. invokeStringGetterSafe(Object o, String name)