ReflectionHelper { <T extends Annotation> List<T> getAnnotationWithMeta(AnnotatedElement element, Class<T> annotation) { return (List) Stream.of(element.getDeclaredAnnotations()) .flatMap(this::addMetaAnnotations) .filter(a -> annotation.isAssignableFrom(a.annotationType())) .collect(Collectors.toList()); }  T newInstance(Class<T> clazz); T newInstance(String className);  }
@Test public void testGetAnnotationWithMeta() throws Exception { ReadOnlyAnnotationTo to = new ReadOnlyAnnotationTo(); Field field = to.getClass().getDeclaredField("twice"); assertThat(reflectionHelper.getAnnotationWithMeta(field, ReadOnly.class)).hasSize(1); assertThat(reflectionHelper.getAnnotationWithMeta(field, MappedBy.class)).hasSize(1); assertThat(reflectionHelper.getAnnotationWithMeta(field, NotMapped.class)).hasSize(0); }