Java Reflection Method Get from Object getMethod(Object target, String methodName, Class... parameterTypes)

Here you can find the source of getMethod(Object target, String methodName, Class... parameterTypes)

Description

Get target method

License

LGPL

Parameter

Parameter Description
target target object
methodName method name
parameterTypes method parameter types

Return

return value

Declaration

public static Method getMethod(Object target, String methodName, Class... parameterTypes) 

Method Source Code

//package com.java2s;
/*//from   ww w.j  a v  a  2  s.  c  om
 * Hibernate, Relational Persistence for Idiomatic Java
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later.
 * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
 */

import java.lang.reflect.Method;

public class Main {
    /**
     * Get target method
     *
     * @param target target object
     * @param methodName method name
     * @param parameterTypes method parameter types
     *
     * @return return value
     */
    public static Method getMethod(Object target, String methodName, Class... parameterTypes) {
        try {
            return target.getClass().getMethod(methodName, parameterTypes);
        } catch (NoSuchMethodException e) {
            throw new IllegalArgumentException(e);
        }
    }
}

Related

  1. getMethod(Object object, String methodName, Class... arguments)
  2. getMethod(Object object, String name, Object... params)
  3. getMethod(Object oo, String mname)
  4. getMethod(Object pojo, String methodName, Class[] params)
  5. getMethod(Object target, String methodName)
  6. getMethod(Object target, String signature)
  7. getMethod(String methodName, Object instance)
  8. getMethodAnnotatedWith(final Class type, final Class annotation, String fieldName, Object fieldValue)
  9. getMethodByName(Object target, String methodName)