Java examples for java.lang.annotation:Annotation Attribute
is Annotation Present
//package com.java2s; import java.lang.annotation.Annotation; public class Main { public static boolean isAnnotationPresent(Class<?> clazz, Class<? extends Annotation> annotationClass, boolean recursive) { boolean isPresent = clazz.isAnnotationPresent(annotationClass); if (isPresent || !recursive || clazz.getSuperclass().equals(Object.class)) { return isPresent; } else {/* ww w.j a v a2 s. co m*/ return isAnnotationPresent(clazz.getSuperclass(), annotationClass, recursive); } } }