AnnotationUtil { static List<Annotation> getAnnotations(AnnotatedElement element, FindOption... findOptions) { requireNonNull(findOptions, "findOptions"); return getAnnotations(element, findOptions.length > 0 ? EnumSet.copyOf(ImmutableList.copyOf(findOptions)) : EnumSet.noneOf(FindOption.class)); } private  AnnotationUtil();   }
@Test public void getAnnotations_declared() { final List<Annotation> list = getAnnotations(TestGrandChildClass.class); assertThat(list).hasSize(2); assertThat(list.get(0)).isInstanceOf(TestRepeatables.class); assertThat(list.get(1)).isInstanceOf(TestAnnotation.class); }
@Test public void getAnnotations_inherited() { final List<Annotation> list = getAnnotations(TestGrandChildClass.class, FindOption.LOOKUP_SUPER_CLASSES); assertThat(list).hasSize(6); assertThat(list.get(0)).isInstanceOf(TestRepeatables.class); assertThat(list.get(1)).isInstanceOf(TestAnnotation.class); assertThat(list.get(2)).isInstanceOf(TestRepeatables.class); assertThat(list.get(3)).isInstanceOf(TestAnnotation.class); assertThat(list.get(4)).isInstanceOf(TestRepeatables.class); assertThat(list.get(5)).isInstanceOf(TestAnnotation.class); }