use of org.reflections.util.QueryFunction in project reflections by ronmamo.
the class ReflectionUtilsQueryTest method mergedAnnotations.
@Test
public void mergedAnnotations() {
Class<CombinedTestModel.Request> metaAnnotation = CombinedTestModel.Request.class;
Reflections reflections = new Reflections(metaAnnotation, Scanners.values());
Set<Class<?>> metaAnnotations = reflections.get(TypesAnnotated.getAllIncluding(metaAnnotation.getName()).asClass());
QueryFunction<Store, CombinedTestModel.Request> mergedAnnotations = MethodsAnnotated.with(metaAnnotations).as(Method.class).map(method -> get(Annotations.of(method.getDeclaringClass()).add(Annotations.of(method)).filter(a -> metaAnnotations.contains(a.annotationType()))).stream().collect(new AnnotationMergeCollector(method))).map(map -> ReflectionUtils.toAnnotation(map, metaAnnotation));
assertThat(reflections.get(mergedAnnotations.map(CombinedTestModel.Request::value)), equalTo("/base/post", "/base/get"));
assertThat(reflections.get(mergedAnnotations.map(CombinedTestModel.Request::method)), equalTo("Post", "Get"));
}
Aggregations