Java Reflection Method Parameter getMethod(final Class clazz, final String methodName, final Class... parameterTypes)

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

Description

get Method

License

Open Source License

Return

the method or null if the method does not exist

Declaration

public static Method getMethod(final Class<?> clazz, final String methodName,
        final Class<?>... parameterTypes) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Portions created by Sebastian Thomschke are copyright (c) 2005-2016 Sebastian
 * Thomschke./*from w w  w .j av  a2  s .  com*/
 *
 * All Rights Reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Sebastian Thomschke - initial implementation.
 *******************************************************************************/

import java.lang.reflect.Method;

public class Main {
    /**
     * @return the method or null if the method does not exist
     */
    public static Method getMethod(final Class<?> clazz, final String methodName,
            final Class<?>... parameterTypes) {
        try {
            return clazz.getDeclaredMethod(methodName, parameterTypes);
        } catch (final NoSuchMethodException ex) {
            return null;
        }
    }
}

Related

  1. getMethod(Class type, String name, Class... parameterTypes)
  2. getMethod(Class clazz, String methodName, Class[] parameterTypes)
  3. getMethod(final Class clazz, final String name, final Class... parameterTypes)
  4. getMethod(final Class javaClass, final String methodName, final Class[] methodParameterTypes, final boolean shouldSetAccessible)
  5. getMethod(final Class aClass, final String methodName, Class[] parameterTypes)
  6. getMethod(final Class clazz, final String name, final Class... parametertypes)
  7. getMethod(final Class clazz, final String name, final Class... parameterTypes)
  8. getMethod(final Class target, final String name, final Class... parameters)
  9. getMethod(final Class receiver, final String methodName, final Class... parameterTypes)