@Test void hasAnnotationNotPresent() { Field field = ClassUtil.getDeclaredField(ClassWithStringField.class, "stringField"); boolean result = FieldUtil.hasAnnotation(XmlAttribute.class, field); assertThat(result, is(false)); }
public static boolean hasAnnotation(Class<? extends Annotation> annotationClass, Field field) { return field.getAnnotation(annotationClass) != null; }
FieldUtil extends UtilityClass { public static boolean hasAnnotation(Class<? extends Annotation> annotationClass, Field field) { return field.getAnnotation(annotationClass) != null; } }
FieldUtil extends UtilityClass { public static boolean hasAnnotation(Class<? extends Annotation> annotationClass, Field field) { return field.getAnnotation(annotationClass) != null; }  }
FieldUtil extends UtilityClass { public static boolean hasAnnotation(Class<? extends Annotation> annotationClass, Field field) { return field.getAnnotation(annotationClass) != null; }  static void set(Field field, Object target, Object value); static Object get(Field field, Object target); static Object get(String fieldName, Object target); static Optional<Class<?>> genericTypeArgument(Field field, int index); static boolean hasAnnotation(Class<? extends Annotation> annotationClass, Field field); static Optional<A> annotation(Class<A> annotationClass, Field field); }
FieldUtil extends UtilityClass { public static boolean hasAnnotation(Class<? extends Annotation> annotationClass, Field field) { return field.getAnnotation(annotationClass) != null; }  static void set(Field field, Object target, Object value); static Object get(Field field, Object target); static Object get(String fieldName, Object target); static Optional<Class<?>> genericTypeArgument(Field field, int index); static boolean hasAnnotation(Class<? extends Annotation> annotationClass, Field field); static Optional<A> annotation(Class<A> annotationClass, Field field);  }