@Test public void testCreateAspectDefinitionsFor_Dynamic() throws NoSuchMethodException, SecurityException { class DynamicFieldTestPmo { @TestComponentAnnotation1(position = 10) @TestComponentAnnotation2(position = 10) @AnotherTestAnnotation @SuppressFBWarnings("UMAC_UNCALLABLE_METHOD_OF_ANONYMOUS_CLASS") public String getDynamic() { return "dyn"; } } AnnotatedElement annotatedElement = DynamicFieldTestPmo.class.getMethod("getDynamic"); List<LinkkiAspectDefinition> definitions = AspectAnnotationReader .createAspectDefinitionsFor(annotatedElement.getAnnotation(TestComponentAnnotation1.class), annotatedElement); assertThat(definitions.size(), is(2)); assertThat(definitions.get(0), is(instanceOf(TestAspectDefinition.class))); assertThat(definitions.get(0), isInitializedWith(TestComponentAnnotation1.class)); assertThat(definitions.get(1), is(instanceOf(TestAspectDefinition.class))); assertThat(definitions.get(1), isInitializedWith(AnotherTestAnnotation.class)); definitions = AspectAnnotationReader .createAspectDefinitionsFor(annotatedElement.getAnnotation(TestComponentAnnotation2.class), annotatedElement); assertThat(definitions.size(), is(2)); assertThat(definitions.get(0), is(instanceOf(YetAnotherTestAspectDefinition.class))); assertThat(definitions.get(0), isInitializedWith(TestComponentAnnotation2.class)); assertThat(definitions.get(1), is(instanceOf(TestAspectDefinition.class))); assertThat(definitions.get(1), isInitializedWith(AnotherTestAnnotation.class)); }
public static List<LinkkiAspectDefinition> createAspectDefinitionsFor(AnnotatedElement annotatedElement) { return getAllAnnotations(annotatedElement) .map(a -> AspectAnnotationReader.createAspectDefinitionsFrom(a)) .flatMap(Collection::stream) .collect(Collectors.toList()); }
AspectAnnotationReader { public static List<LinkkiAspectDefinition> createAspectDefinitionsFor(AnnotatedElement annotatedElement) { return getAllAnnotations(annotatedElement) .map(a -> AspectAnnotationReader.createAspectDefinitionsFrom(a)) .flatMap(Collection::stream) .collect(Collectors.toList()); } }
AspectAnnotationReader { public static List<LinkkiAspectDefinition> createAspectDefinitionsFor(AnnotatedElement annotatedElement) { return getAllAnnotations(annotatedElement) .map(a -> AspectAnnotationReader.createAspectDefinitionsFrom(a)) .flatMap(Collection::stream) .collect(Collectors.toList()); } private  AspectAnnotationReader(); }
AspectAnnotationReader { public static List<LinkkiAspectDefinition> createAspectDefinitionsFor(AnnotatedElement annotatedElement) { return getAllAnnotations(annotatedElement) .map(a -> AspectAnnotationReader.createAspectDefinitionsFrom(a)) .flatMap(Collection::stream) .collect(Collectors.toList()); } private  AspectAnnotationReader(); static List<LinkkiAspectDefinition> createAspectDefinitionsFrom(
            UI_ANNOTATION uiAnnotation); static List<LinkkiAspectDefinition> createAspectDefinitionsFor(AnnotatedElement annotatedElement); static List<LinkkiAspectDefinition> createAspectDefinitionsFor(Annotation componentDefAnnotation,
            AnnotatedElement annotatedElement); }
AspectAnnotationReader { public static List<LinkkiAspectDefinition> createAspectDefinitionsFor(AnnotatedElement annotatedElement) { return getAllAnnotations(annotatedElement) .map(a -> AspectAnnotationReader.createAspectDefinitionsFrom(a)) .flatMap(Collection::stream) .collect(Collectors.toList()); } private  AspectAnnotationReader(); static List<LinkkiAspectDefinition> createAspectDefinitionsFrom(
            UI_ANNOTATION uiAnnotation); static List<LinkkiAspectDefinition> createAspectDefinitionsFor(AnnotatedElement annotatedElement); static List<LinkkiAspectDefinition> createAspectDefinitionsFor(Annotation componentDefAnnotation,
            AnnotatedElement annotatedElement);  }