Java Reflection Method Name getMethod(Class clazz, String name)

Here you can find the source of getMethod(Class clazz, String name)

Description

get Method

License

Open Source License

Declaration

private static Method getMethod(Class clazz, String name) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2006-2010 eBay Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *******************************************************************************/

import java.lang.reflect.Method;

public class Main {
    private static Method getMethod(Class clazz, String name) {
        Method[] methods = clazz.getMethods();
        if (methods == null) {
            return null;
        }//from   w  ww. j a  v a 2s .  c  o  m

        for (int i = 0; i < methods.length; i++) {
            Method method = methods[i];
            if (name.equals(method.getName())) {
                return method;
            }
        }

        return null;
    }
}

Related

  1. getMethod(Class cl, String methodName, Class[] paramTypes)
  2. getMethod(Class clazz, String methodName)
  3. getMethod(Class clazz, String methodName, Class argType)
  4. getMethod(Class clazz, String methodName, Class[] classes)
  5. getMethod(Class clazz, String methodName, Class[] params)
  6. getMethod(Class clazz, String name, Class... args)
  7. getMethod(Class cls, String methodName, Class[] params)
  8. getMethod(Class clz, String methodName, Class expectedTypes[])
  9. getMethod(Class klazz, String[] methodNames, int argCount)