Java examples for java.lang.annotation:Class Annotation
is Annotation Exists on Class
//package com.java2s; import java.lang.annotation.Annotation; import java.lang.reflect.Field; import java.lang.reflect.Method; public class Main { public static boolean isExists(Class<?> clazz, Annotation annotation) { Annotation existingAnnotation = clazz.getAnnotation(annotation .annotationType());// w ww.jav a 2 s . com return existingAnnotation != null; } public static boolean isExists(Method method, Annotation annotation) { Annotation existingAnnotation = method.getAnnotation(annotation .annotationType()); return existingAnnotation != null; } public static boolean isExists(Field field, Annotation annotation) { Annotation existingAnnotation = field.getAnnotation(annotation .annotationType()); return existingAnnotation != null; } }