Here you can find the source of findAnnotation(Class> aClass, Class extends Annotation> annotationClass)
Parameter | Description |
---|---|
aClass | a parameter |
annotationClass | a parameter |
public static Annotation findAnnotation(Class<?> aClass, Class<? extends Annotation> annotationClass)
//package com.java2s; // it under the terms of the GNU Lesser General Public License as published by import java.lang.annotation.Annotation; public class Main { /**//from w ww. j a va 2 s . c om * Finds an annotation of the class aClass by looking for an annotation matching the class annotationClass * * @param aClass * @param annotationClass * @return */ public static Annotation findAnnotation(Class<?> aClass, Class<? extends Annotation> annotationClass) { for (Annotation annotation : aClass.getAnnotations()) { if (annotation.annotationType().equals(annotationClass)) { return annotation; } } return null; } public static Annotation findAnnotation(Object object, Class<? extends Annotation> annotationClass) { return findAnnotation(object.getClass(), annotationClass); } }