|
|
@ -40,18 +40,22 @@ public class UfClassHelper { |
|
|
|
} |
|
|
|
|
|
|
|
// invoke method |
|
|
|
public static Object invokeMethod(Object obj, String methodName, List<Object> args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { |
|
|
|
public static Object invokeMethod(Object obj, String methodName, List<Object> args) throws Throwable { |
|
|
|
Class<?>[] parameterTypes = new Class<?>[args.size()]; |
|
|
|
for (int i = 0; i < args.size(); i++) { |
|
|
|
parameterTypes[i] = args.get(i).getClass(); |
|
|
|
} |
|
|
|
Method method = obj.getClass().getMethod(methodName, parameterTypes); |
|
|
|
|
|
|
|
if ( method.getReturnType().equals(Void.TYPE) ) { |
|
|
|
method.invoke(obj, args.toArray()); |
|
|
|
return null; |
|
|
|
} else { |
|
|
|
return method.invoke(obj, args.toArray()); |
|
|
|
try { |
|
|
|
if ( method.getReturnType().equals(Void.TYPE) ) { |
|
|
|
method.invoke(obj, args.toArray()); |
|
|
|
return null; |
|
|
|
} else { |
|
|
|
return method.invoke(obj, args.toArray()); |
|
|
|
} |
|
|
|
} catch ( Exception e ) { |
|
|
|
throw e.getCause(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|