Source Code : Get all methods of a class.

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

Get all methods of a class.

      
//package org.nestframework.utils;

import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;


/**
 * Nest utility class.
 * 
 * @author audin
 *
 */
public class NestUtil {

  /**
   * Get all methods of a class.
   * 
   * @param clazz The class.
   * @return All methods of a class.
   */
  public static Collection<Method> getMethods(Class<?> clazz) {
  //  if (log.isDebugEnabled()) {
    //  log.debug("getMethods(Class<?>) - start");
  //  }

    Collection<Method> found = new ArrayList<Method>();
    while (clazz != null) {
      for (Method m1 : clazz.getDeclaredMethods()) {
        boolean overridden = false;

        for (Method m2 : found) {
          if (m2.getName().equals(m1.getName())
              && Arrays.deepEquals(m1.getParameterTypes(), m2
                  .getParameterTypes())) {
            overridden = true;
            break;
          }
        }

        if (!overridden)
          found.add(m1);
      }

      clazz = clazz.getSuperclass();
    }

    //if (log.isDebugEnabled()) {
    //  log.debug("getMethods(Class<?>) - end");
  //  }
    return found;
  }
}

   
    
    
    
    
    
  

Thank with us