@Test public void getAnnotatedMethodShouldReturnEmptyOptionalWhenAnnotationNotFound() { Optional<Method> whenMethod = getAnnotatedMethod(When.class, SampleRuleWithoutRuleAnnotation.class); Assert.assertFalse(whenMethod.isPresent()); }
public static Optional<Method> getAnnotatedMethod(Class annotation, Class clazz) { List<Method> methods = getAnnotatedMethods(annotation, clazz); return Optional.ofNullable(methods.size() > 0 ? methods.get(0) : null); }
AnnotationUtils { public static Optional<Method> getAnnotatedMethod(Class annotation, Class clazz) { List<Method> methods = getAnnotatedMethods(annotation, clazz); return Optional.ofNullable(methods.size() > 0 ? methods.get(0) : null); } }
AnnotationUtils { public static Optional<Method> getAnnotatedMethod(Class annotation, Class clazz) { List<Method> methods = getAnnotatedMethods(annotation, clazz); return Optional.ofNullable(methods.size() > 0 ? methods.get(0) : null); } private  AnnotationUtils(); }
AnnotationUtils { public static Optional<Method> getAnnotatedMethod(Class annotation, Class clazz) { List<Method> methods = getAnnotatedMethods(annotation, clazz); return Optional.ofNullable(methods.size() > 0 ? methods.get(0) : null); } private  AnnotationUtils(); @SuppressWarnings("unchecked") static List<Field> getAnnotatedFields(Class annotation, Class clazz); static Optional<Field> getAnnotatedField(Class annotation, Class clazz); @SuppressWarnings("unchecked") static List<Method> getAnnotatedMethods(Class annotation, Class clazz); static Optional<Method> getAnnotatedMethod(Class annotation, Class clazz); @SuppressWarnings("unchecked") static A getAnnotation(Class<A> annotation, Class<?> clazz); }
AnnotationUtils { public static Optional<Method> getAnnotatedMethod(Class annotation, Class clazz) { List<Method> methods = getAnnotatedMethods(annotation, clazz); return Optional.ofNullable(methods.size() > 0 ? methods.get(0) : null); } private  AnnotationUtils(); @SuppressWarnings("unchecked") static List<Field> getAnnotatedFields(Class annotation, Class clazz); static Optional<Field> getAnnotatedField(Class annotation, Class clazz); @SuppressWarnings("unchecked") static List<Method> getAnnotatedMethods(Class annotation, Class clazz); static Optional<Method> getAnnotatedMethod(Class annotation, Class clazz); @SuppressWarnings("unchecked") static A getAnnotation(Class<A> annotation, Class<?> clazz);  }