Mega Code Archive

 
Categories / Java / Reflection
 

Is Field Annotation Present

import java.lang.annotation.Annotation; import java.lang.reflect.Field; public class Util{   public static boolean isFieldAnnotationPresent(Class<?> clazz, String fieldName, Class<? extends Annotation> annotationClass) throws NoSuchFieldException {     Field field = clazz.getDeclaredField(fieldName);     return(field.isAnnotationPresent(annotationClass));   } }