@DisplayName("Given a dynamic field annotated with both @TestUIField and @TestUIField2,") @ParameterizedTest(name = "when the get~ComponentType method returns {0}") @ValueSource(classes = { TestUIField.class, TestUIField2.class }) public void testCreateUiElements_DynamicField(Class<?> componentType) { class DynamicFieldTestPmo { @SuppressFBWarnings("UMAC_UNCALLABLE_METHOD_OF_ANONYMOUS_CLASS") @TestUIField(position = 10) @TestUIField2(position = 10) public String getDynamic() { return "dyn"; } @SuppressFBWarnings("UMAC_UNCALLABLE_METHOD_OF_ANONYMOUS_CLASS") public Class<?> getDynamicComponentType() { return componentType; } } DynamicFieldTestPmo testPmo = new DynamicFieldTestPmo(); BindingContext bindingContext = new BindingContext(); List<TestUiComponent> components = UiCreator .createUiElements(testPmo, bindingContext, TestComponentWrapper::new) .map(TestComponentWrapper::getComponent) .collect(Collectors.toList()); assertThat(components, hasSize(1)); if (componentType.equals(TestUIField.class)) { assertThat(components.get(0), is(not(instanceOf(TestUIField2.TestUiComponent2.class)))); } else if (componentType.equals(TestUIField2.class)) { assertThat(components.get(0), is(instanceOf(TestUIField2.TestUiComponent2.class))); } }
public static <C, W extends ComponentWrapper> Stream<W> createUiElements(Object pmo, BindingContext bindingContext, Function<C, W> componentWrapperCreator) { return ComponentAnnotationReader.getComponentDefinitionMethods(pmo.getClass()) .map(m -> createUiElement(m, pmo, bindingContext, componentWrapperCreator)); }
UiCreator { public static <C, W extends ComponentWrapper> Stream<W> createUiElements(Object pmo, BindingContext bindingContext, Function<C, W> componentWrapperCreator) { return ComponentAnnotationReader.getComponentDefinitionMethods(pmo.getClass()) .map(m -> createUiElement(m, pmo, bindingContext, componentWrapperCreator)); } }
UiCreator { public static <C, W extends ComponentWrapper> Stream<W> createUiElements(Object pmo, BindingContext bindingContext, Function<C, W> componentWrapperCreator) { return ComponentAnnotationReader.getComponentDefinitionMethods(pmo.getClass()) .map(m -> createUiElement(m, pmo, bindingContext, componentWrapperCreator)); } private  UiCreator(); }
UiCreator { public static <C, W extends ComponentWrapper> Stream<W> createUiElements(Object pmo, BindingContext bindingContext, Function<C, W> componentWrapperCreator) { return ComponentAnnotationReader.getComponentDefinitionMethods(pmo.getClass()) .map(m -> createUiElement(m, pmo, bindingContext, componentWrapperCreator)); } private  UiCreator(); static Stream<W> createUiElements(Object pmo,
            BindingContext bindingContext,
            Function<C, W> componentWrapperCreator); static W createUiElement(AnnotatedElement annotatedElement,
            Object pmo,
            BindingContext bindingContext,
            Function<C, W> componentWrapperCreator); static ComponentWrapper createComponent(Object pmo,
            BindingContext bindingContext); @Deprecated @SuppressWarnings("overloads") static ComponentWrapper createComponent(Object pmo,
            BindingContext bindingContext,
            Function<Class<?>, Optional<LinkkiComponentDefinition>> componentDefinitionFinder,
            Function<Class<?>, Optional<LinkkiLayoutDefinition>> layoutDefinitionFinder); @SuppressWarnings("overloads") static ComponentWrapper createComponent(Object pmo,
            BindingContext bindingContext,
            LinkkiComponentDefinition componentDefinition,
            Optional<LinkkiLayoutDefinition> layoutDefinition); }
UiCreator { public static <C, W extends ComponentWrapper> Stream<W> createUiElements(Object pmo, BindingContext bindingContext, Function<C, W> componentWrapperCreator) { return ComponentAnnotationReader.getComponentDefinitionMethods(pmo.getClass()) .map(m -> createUiElement(m, pmo, bindingContext, componentWrapperCreator)); } private  UiCreator(); static Stream<W> createUiElements(Object pmo,
            BindingContext bindingContext,
            Function<C, W> componentWrapperCreator); static W createUiElement(AnnotatedElement annotatedElement,
            Object pmo,
            BindingContext bindingContext,
            Function<C, W> componentWrapperCreator); static ComponentWrapper createComponent(Object pmo,
            BindingContext bindingContext); @Deprecated @SuppressWarnings("overloads") static ComponentWrapper createComponent(Object pmo,
            BindingContext bindingContext,
            Function<Class<?>, Optional<LinkkiComponentDefinition>> componentDefinitionFinder,
            Function<Class<?>, Optional<LinkkiLayoutDefinition>> layoutDefinitionFinder); @SuppressWarnings("overloads") static ComponentWrapper createComponent(Object pmo,
            BindingContext bindingContext,
            LinkkiComponentDefinition componentDefinition,
            Optional<LinkkiLayoutDefinition> layoutDefinition);  }