Java Utililty Methods Method Call

List of utility methods to do Method Call

Description

The list of methods to do Method Call are organized into topic(s).

Method

Objectinvoke(Object invoker, String cmd, Map params)
invoke
Method method = invoker.getClass().getMethod(cmd, Map.class);
return method.invoke(invoker, params);
Objectinvoke(Object methodHostInstance, String methodName, Class[] parameterTypes, Object[] args)
invoke
try {
    Method method = methodHostInstance.getClass().getDeclaredMethod(methodName, parameterTypes);
    method.setAccessible(true);
    try {
        Object result = method.invoke(methodHostInstance, args);
        return result;
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
...
Objectinvoke(Object o, Method m)
invoke
Object ret = null;
try {
    ret = m.invoke(o);
} catch (Exception e) {
return ret;
Objectinvoke(Object o, Method method, Object... param)
invoke
return method.invoke(o, param);
Objectinvoke(Object o, String m, Object... params)
invoke
return invoke(o.getClass(), o, m, params);
Objectinvoke(Object o, String method, Object... args)
invoke
Class[] argTypes = new Class[args.length];
for (int i = 0; i < args.length; i++) {
    argTypes[i] = args.getClass();
Method mthd = method(method, o.getClass());
mthd.setAccessible(true);
return mthd.invoke(o, args);
Objectinvoke(Object o, String name)
Invoke zero parameter method name.
try {
    Method method = o.getClass().getMethod(name);
    method.setAccessible(true);
    return method.invoke(o);
} catch (Exception e) {
    return null;
Objectinvoke(Object o, String name, Object[] args)
invoke
return invoke(o.getClass(), o, name, args);
Objectinvoke(Object o, String name, Object[] args)
invoke
return invoke(o.getClass(), o, name, args);
Objectinvoke(Object obj, Method method, Object[] args)
invoke
if (obj == null)
    throw new NullPointerException("invoke target object is NULL.");
if (method.getDeclaringClass().isAssignableFrom(obj.getClass())) {
    return method.invoke(obj, args);
} else {
    return obj.getClass().getMethod(method.getName(), method.getParameterTypes()).invoke(obj, args);