Java Reflection Method Return getMethode(Class clasS, Class Returntype, int modifier, Class... classes)

Here you can find the source of getMethode(Class clasS, Class Returntype, int modifier, Class... classes)

Description

get Methode

License

Open Source License

Declaration

public static Method getMethode(Class clasS, Class Returntype, int modifier, Class... classes) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.lang.reflect.Method;

public class Main {
    public static Method getMethode(Class clasS, Class Returntype, int modifier, Class... classes) {
        for (Method m : clasS.getDeclaredMethods()) {
            if (HasParametersignature(m, classes) && m.getReturnType().isAssignableFrom(Returntype)
                    && m.getModifiers() == modifier)
                return m;
        }//from  w w w .  j  av  a  2 s  . co  m
        return null;
    }

    private static boolean HasParametersignature(Method method, Class... classes) {
        if (method.getParameterTypes().length == classes.length) {
            for (int i = 0; i < classes.length; i++) {
                if (!classes[i].isAssignableFrom(method.getParameterTypes()[i]))
                    return false;
            }
            return true;
        }
        return false;
    }
}

Related

  1. getMethod(Class parentClass, Class returnType, String methodName, Class... types)
  2. getMethod(Class type, String name, Class returnType, Class paramType, boolean caseSensitive)
  3. getMethodByReturnType(final Class source, final Class type)
  4. getMethodByTypes(Class clazz, String name, Class returnType, Class... parameterTypes)
  5. getMethodDesc(Class returnType, Class... params)
  6. getMethodGenericReturnType(Method method, Class rawType, int index)
  7. getMethodGenericReturnType(Method method, int index)
  8. getMethodGenericReturnType(Method method, int index)
  9. getMethodInvoker(final Class returnType, final String methodName)