private Object [ ] convertArguments ( Object obj , String methodName , Object [ ] args ) { for ( Method method : obj . getClass ( ) . getMethods ( ) ) { if ( method . getName ( ) . equalsIgnoreCase ( methodName ) && ( method . getGenericParameterTypes ( ) . length == args . length || method . isVarArgs ( ) ) ) { try { return convertArguments ( args , method . getGenericParameterTypes ( ) , method . isVarArgs ( ) ) ; } catch ( Exception e ) { // Ignore and try the next method. } } } return null ; }
Converts the given arguments to match a method with the specified name and the same number of formal parameters as the number of arguments .