public static Object applyMethod ( Object pObject , String pMethod , Object ... pArgs ) { Class < ? > clazz = pObject . getClass ( ) ; try { Method method = extractMethod ( pMethod , clazz , pArgs ) ; return method . invoke ( pObject , pArgs ) ; } catch ( NoSuchMethodException e ) { throw new IllegalArgumentException ( "Cannot call method " + pMethod + " on " + pObject + ": " + e , e ) ; } catch ( InvocationTargetException e ) { throw new IllegalArgumentException ( "Cannot call method " + pMethod + " on " + pObject + ": " + e , e ) ; } catch ( IllegalAccessException e ) { throw new IllegalArgumentException ( "Cannot call method " + pMethod + " on " + pObject + ": " + e , e ) ; } }
Apply a method to a given object with optional arguments . The method is looked up the whole class hierarchy .