Java examples for java.lang.annotation:Class Annotation
Checks the class to have the given annotation.
//package com.java2s; import java.lang.annotation.Annotation; public class Main { /**/* w w w . j a v a 2 s .co m*/ * Checks the class to have the given annotation. * * @param clazz * The class to check. * @param annotation * The annotation to check. * @return True if class has annotation. False otherwise. */ public static boolean hasAnnotation(Class<?> clazz, Class<? extends Annotation> annotation) { Annotation found = clazz.getAnnotation(annotation); return found != null; } }