Here you can find the source of invoke(Object obj, String methodName, boolean newValue)
public static Object invoke(Object obj, String methodName, boolean newValue) throws NoSuchMethodException
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Method; import java.lang.reflect.InvocationTargetException; public class Main { public static Object invoke(Object obj, String methodName, boolean newValue) throws NoSuchMethodException { try {/*from w ww.ja v a2 s.c o m*/ Method method = obj.getClass().getMethod(methodName, new Class[] { Boolean.TYPE }); return method.invoke(obj, new Object[] { new Boolean(newValue) }); } catch (IllegalAccessException e) { throw new NoSuchMethodException(methodName + " is not accessible"); } catch (InvocationTargetException e) { // The method is not supposed to throw exceptions throw new InternalError(e.getMessage()); } } public static Object invoke(Object obj, String methodName, int newValue) throws NoSuchMethodException { try { Method method = obj.getClass().getMethod(methodName, new Class[] { Integer.TYPE }); return method.invoke(obj, new Object[] { new Integer(newValue) }); } catch (IllegalAccessException e) { throw new NoSuchMethodException(methodName + " is not accessible"); } catch (InvocationTargetException e) { // The method is not supposed to throw exceptions throw new InternalError(e.getMessage()); } } public static Object invoke(Object obj, String methodName, float newValue) throws NoSuchMethodException { try { Method method = obj.getClass().getMethod(methodName, new Class[] { Float.TYPE }); return method.invoke(obj, new Object[] { new Float(newValue) }); } catch (IllegalAccessException e) { throw new NoSuchMethodException(methodName + " is not accessible"); } catch (InvocationTargetException e) { // The method is not supposed to throw exceptions throw new InternalError(e.getMessage()); } } }