Java Reflection Method Annotation getMethod(Class compClassOrSuper, Class annotation)

Here you can find the source of getMethod(Class compClassOrSuper, Class annotation)

Description

Checks for annotation of the class

License

LGPL

Parameter

Parameter Description
compClassOrSuper a parameter
annotation a parameter

Declaration


private static Method getMethod(Class<?> compClassOrSuper, Class<? extends Annotation> annotation) 

Method Source Code


//package com.java2s;
//License from project: LGPL 

import java.lang.annotation.Annotation;

import java.lang.reflect.Method;

public class Main {
    /**/*w w w. j a va 2  s.  c  om*/
     * Checks for annotation of the class
     * @param compClassOrSuper
     * @param annotation
     * @return
     */

    private static Method getMethod(Class<?> compClassOrSuper, Class<? extends Annotation> annotation) {
        for (Method m : compClassOrSuper.getMethods()) {
            if (m.getAnnotation(annotation) != null) {
                return m;
            }
        }
        return null;
    }
}

Related

  1. getMethod(Class annotationClass, Class aClass)
  2. getMethodAnnotatedWith(Class toIntrospect, Class c)
  3. getMethodAnnotation(Class a, Method m)
  4. getMethodAnnotation(final Method method, final Class annoClass)
  5. getMethodAnnotation(final Method method, final Class annotationType)