Java Reflection Method Parameter getMethodByParametersWithAnnotation(final Class source, final Class[] params, final Class annotation)

Here you can find the source of getMethodByParametersWithAnnotation(final Class source, final Class[] params, final Class annotation)

Description

get Method By Parameters With Annotation

License

Open Source License

Declaration

public static Method getMethodByParametersWithAnnotation(final Class<?> source, final Class<?>[] params,
            final Class<? extends Annotation> annotation) 

Method Source Code


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

import java.lang.annotation.Annotation;

import java.lang.reflect.Method;
import java.util.Arrays;

public class Main {
    public static Method getMethodByParametersWithAnnotation(final Class<?> source, final Class<?>[] params,
            final Class<? extends Annotation> annotation) {
        for (final Method e : source.getDeclaredMethods()) {
            if (Arrays.deepEquals(e.getParameterTypes(), params)) {
                if (e.isAnnotationPresent(annotation)) {
                    return e;
                }/* www  . j a v  a2s.  c  o  m*/
            }
        }
        return null;
    }
}

Related

  1. getMethod(String classFullName, String methodName, Class... parameterTypes)
  2. getMethod0(Class c, String name, Class... parameterTypes)
  3. getMethod0(Class target, String name, Class[] parameterTypes)
  4. getMethodAnnotations(String className, String methodName, Class[] parameterTypes)
  5. getMethodByName(Class clazz, String name, Class... parameterTypes)
  6. getMethodFromClass(String className, String methodName, Class... parameterTypes)
  7. getMethodFromClassName(String classAndMethodName, Class... parameterTypes)
  8. getMethodFullName(Method m, boolean includeClassPackage, boolean includeParametersType, boolean includeTypesPackage)
  9. getMethodGenericParameterTypes(Method method, int index)