Java Reflection Annotation Find findAnnotation(final Class annotationClass, final Class beanClass, final Field field)

Here you can find the source of findAnnotation(final Class annotationClass, final Class beanClass, final Field field)

Description

find Annotation

License

Apache License

Declaration

public static <T extends Annotation> T findAnnotation(final Class<T> annotationClass, final Class<?> beanClass,
            final Field field) 

Method Source Code


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

import java.lang.annotation.Annotation;

import java.lang.reflect.Field;

public class Main {
    public static <T extends Annotation> T findAnnotation(final Class<T> annotationClass, final Class<?> beanClass,
            final Field field) {
        final T fieldAnnotation = field.getAnnotation(annotationClass);
        return fieldAnnotation == null ? beanClass.getAnnotation(annotationClass) : fieldAnnotation;
    }//  w  w w  .j  a  v  a  2 s. c om
}

Related

  1. findAnnotation(Class klass, Class annotationClass)
  2. findAnnotation(final Class clazz, final Class type)
  3. findAnnotation(final Class clazz, final Class annotation)
  4. findAnnotation(final Class type, final Class annotationType)
  5. findAnnotation(final Class targetAnnotation, final Class annotatedType)
  6. findAnnotation(final Set annotations, final Class annotationType)
  7. findAnnotation(Method method, Class annotationType)
  8. findAnnotation(Method method, Class type)
  9. findAnnotation(Set annotations, Class annotationClass)