Invokes a method if it exists otherwise returns null

@param instance The instance
@param methodName The method name
@return The result of the method call or null
420893
public static Object invokeMethodIfExists(Object instance, String methodName) {
        return invokeMethodIfExists(instance, methodName, NO_ARGS);
    }
752776
@Override
  public MethodAmp methodByName(String methodName)
  {
    StubAmp delegate = delegate();
    
    if (delegate != null) {
      return delegate.methodByName(methodName);
    }
    else {
      System.out.println("EEP:");
      return null;
    }
  }
91807
function instanceMethod(method) {
		return function (req, res, next) {

			var done = function (err, data) {
				if (err) {
					return res.status(400).send(err);
				}
				return res.send(data);
			};

			var id = req.params.id;
			if (id) {
				Model.findById(id, function (err, data) {
					if (err) {
						debug('Method middleware Model.findById error:', err);
						return next(err);
					}
					if (data) {
						data[method](req, res, done, next);
					} else {
						return res.status(404).send();
					}
				});
			} else {
				return res.status(404).send();
			}
		};
	}
549684
public static Object invokeMethod(Object object, String methodName, Object[] parameters) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        return invokeMethod(object, methodName, getTypes(parameters), parameters);
    }
1310135
public static Object invokeMethod(Object object, Method method, Object... args) throws Throwable {
        try {
            return method.invoke(object, args);
        } catch (InvocationTargetException e) {
            throw e.getTargetException();
        }
    }
1324452
public static Object invokeObjectMethod(
            Object object, String methodName, Object[] args,
            Interpreter interpreter, CallStack callstack,
            SimpleNode callerInfo ) throws ReflectError, EvalError,
            InvocationTargetException {
        // Bsh scripted object
        if ( object instanceof This && !This.isExposedThisMethod(methodName) )
            return ((This)object).invokeMethod(
                methodName, args, interpreter, callstack, callerInfo,
                false/*delcaredOnly*/);

        // Plain Java object, find the java method
        try {
            BshClassManager bcm =
                interpreter == null ? null : interpreter.getClassManager();
            Class<?> clas = object.getClass();

            Invocable method = resolveExpectedJavaMethod(
                bcm, clas, object, methodName, args, false );
            NameSpace ns = getThisNS(object);
            if (null != ns)
                ns.setNode(callerInfo);
            return method.invoke(object, args);
        } catch ( UtilEvalError e ) {
            throw e.toEvalError( callerInfo, callstack );
        }
    }
753649
public static MockMethodDispatcher get(String identifier, Object instance) {
        if (instance == INSTANCE) {
            // Avoid endless loop if ConcurrentHashMap was redefined to check for being a mock.
            return null;
        } else {
            return INSTANCE.get(identifier);
        }
    }
350583
public static <T> T invoke(String className, String methodName, Object[] args) {
		return invoke(className, methodName, false, args);
	}
60763
public <X> X invoke(Object instance, Object... parameters) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
        return cast(annotatedMethod.getJavaMember().invoke(instance, parameters));
    }
1221287
public static Object invokeMethod(final Object obj, final String methodName, final Class<?>[] parameterTypes,
			final Object[] args) {
		Method method = getAccessibleMethod(obj, methodName, parameterTypes);
		if (method == null) {
			throw new IllegalArgumentException("Could not find method [" + methodName + "] on target [" + obj + "]");
		}

		try {
			return method.invoke(obj, args);
		} catch (Exception e) {
			throw convertReflectionExceptionToUnchecked(e);
		}
	}
13663
def method_instance
    lazy_var :@method_instance do
      # Just drop a warning if we can't get the method object
      logger.catch.warn(
        "Failed to get method",
        instance: instance,
        method_name: method_name,
      ) do
        instance.method method_name
      end
    end
  end
205943
private static Method getMethod(String methodName, Class<?> clazz, Class<?>... args) {
        Method method;
        try {
            method = clazz.getMethod(methodName, args);
        } catch (NoSuchMethodException e1) {
            method = null;
        }
        return method;
    }
792911
public Object invokeMethod(String name, Object args) {
        try {
        return getMetaClass().invokeMethod(this, name, args);
        }
        catch (MissingMethodException e) {
            // lets apply the method to each item in the collection
            List answer = new ArrayList(size());
            for (Iterator iter = iterator(); iter.hasNext(); ) {
                Object element = iter.next();
                Object value = InvokerHelper.invokeMethod(element, name, args);
                answer.add(value);
            }
            return answer;
        }
    }
955241
@Override
  public MethodRefAmp methodByName(String methodName)
  {
    try {
      return delegate().methodByName(methodName);
    } catch (Exception e) {
      return new MethodRefException(this, methodName, e);
    }
  }
903972
private function callMethod($instance, $method)
    {
        if (!method_exists($instance, $method) || !is_callable([$instance, $method])) {
            return false;
        }

        return call_user_func([$instance, $method]);
    }
1194978
public <X> X invokeOnInstance(Object instance, Object... parameters) throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
        final Map<Class<?>, Method> methods = this.methods;
        Method method = methods.get(instance.getClass());
        if (method == null) {
            // the same method may be written to the map twice, but that is ok
            // lookupMethod is very slow
            Method delegate = annotatedMethod.getJavaMember();
            method = SecurityActions.lookupMethod(instance.getClass(), delegate.getName(), delegate.getParameterTypes());
            SecurityActions.ensureAccessible(method);
            synchronized (this) {
                final Map<Class<?>, Method> newMethods = new HashMap<Class<?>, Method>(methods);
                newMethods.put(instance.getClass(), method);
                this.methods = WeldCollections.immutableMapView(newMethods);
            }
        }
        return cast(method.invoke(instance, parameters));
    }
4420
private static Object _runMethod(Object obj, String methodName)
    {
        try
        {
            Method sessionIdMethod = obj.getClass().getMethod(methodName);
            return sessionIdMethod.invoke(obj);
        }
        catch (Exception e)
        {
            return null;
        }

    }