@Test public void testHandleNullItems_ComboBox() { HasItemsAvailableValuesAspectDefinition hasItemsAvailableValuesAspectDefinition = new HasItemsAvailableValuesAspectDefinition( AvailableValuesType.DYNAMIC); ComboBox<TestEnum> comboBox = new ComboBox<>(); hasItemsAvailableValuesAspectDefinition.handleNullItems(new LabelComponentWrapper(comboBox), new LinkedList<>(Arrays.asList(TestEnum.ONE, null))); assertThat(comboBox.isEmptySelectionAllowed()); hasItemsAvailableValuesAspectDefinition.handleNullItems(new LabelComponentWrapper(comboBox), new LinkedList<>(Arrays.asList(TestEnum.TWO))); assertThat(comboBox.isEmptySelectionAllowed(), is(false)); }
@SuppressWarnings("unchecked") @Override protected void handleNullItems(ComponentWrapper componentWrapper, List<?> items) { Object component = componentWrapper.getComponent(); if (component instanceof ComboBox<?>) { boolean hasNullItem = items.removeIf(i -> i == null); ((ComboBox<Object>)component).setEmptySelectionAllowed(hasNullItem); } else if (component instanceof NativeSelect<?>) { boolean hasNullItem = items.removeIf(i -> i == null); ((NativeSelect<Object>)component).setEmptySelectionAllowed(hasNullItem); } }
HasItemsAvailableValuesAspectDefinition extends AvailableValuesAspectDefinition<HasItems<?>> { @SuppressWarnings("unchecked") @Override protected void handleNullItems(ComponentWrapper componentWrapper, List<?> items) { Object component = componentWrapper.getComponent(); if (component instanceof ComboBox<?>) { boolean hasNullItem = items.removeIf(i -> i == null); ((ComboBox<Object>)component).setEmptySelectionAllowed(hasNullItem); } else if (component instanceof NativeSelect<?>) { boolean hasNullItem = items.removeIf(i -> i == null); ((NativeSelect<Object>)component).setEmptySelectionAllowed(hasNullItem); } } }
HasItemsAvailableValuesAspectDefinition extends AvailableValuesAspectDefinition<HasItems<?>> { @SuppressWarnings("unchecked") @Override protected void handleNullItems(ComponentWrapper componentWrapper, List<?> items) { Object component = componentWrapper.getComponent(); if (component instanceof ComboBox<?>) { boolean hasNullItem = items.removeIf(i -> i == null); ((ComboBox<Object>)component).setEmptySelectionAllowed(hasNullItem); } else if (component instanceof NativeSelect<?>) { boolean hasNullItem = items.removeIf(i -> i == null); ((NativeSelect<Object>)component).setEmptySelectionAllowed(hasNullItem); } } HasItemsAvailableValuesAspectDefinition(AvailableValuesType availableValuesType); }
HasItemsAvailableValuesAspectDefinition extends AvailableValuesAspectDefinition<HasItems<?>> { @SuppressWarnings("unchecked") @Override protected void handleNullItems(ComponentWrapper componentWrapper, List<?> items) { Object component = componentWrapper.getComponent(); if (component instanceof ComboBox<?>) { boolean hasNullItem = items.removeIf(i -> i == null); ((ComboBox<Object>)component).setEmptySelectionAllowed(hasNullItem); } else if (component instanceof NativeSelect<?>) { boolean hasNullItem = items.removeIf(i -> i == null); ((NativeSelect<Object>)component).setEmptySelectionAllowed(hasNullItem); } } HasItemsAvailableValuesAspectDefinition(AvailableValuesType availableValuesType);  }
HasItemsAvailableValuesAspectDefinition extends AvailableValuesAspectDefinition<HasItems<?>> { @SuppressWarnings("unchecked") @Override protected void handleNullItems(ComponentWrapper componentWrapper, List<?> items) { Object component = componentWrapper.getComponent(); if (component instanceof ComboBox<?>) { boolean hasNullItem = items.removeIf(i -> i == null); ((ComboBox<Object>)component).setEmptySelectionAllowed(hasNullItem); } else if (component instanceof NativeSelect<?>) { boolean hasNullItem = items.removeIf(i -> i == null); ((NativeSelect<Object>)component).setEmptySelectionAllowed(hasNullItem); } } HasItemsAvailableValuesAspectDefinition(AvailableValuesType availableValuesType);   }