getSelectedItems() must return a copy to fulfill the contract specified
in SelectionModel: it must be a snapshot of the current state and safe
to iterate over while changing selection.
Change-Id: Ie2f15eb626dd80df2036bcb2d4e9387fc31389c9
@Override
public Set<T> getSelectedItems() {
- return Collections.unmodifiableSet(selection);
+ return Collections.unmodifiableSet(new LinkedHashSet<>(selection));
}
@Override
assertEquals(Collections.singleton(TestEnum.TWO), item.getEnums());
}
+ @Test
+ public void bound_setSelection_beanValueIsACopy() {
+ bindEnum();
+
+ select.select(TestEnum.TWO);
+
+ Set<TestEnum> enums = item.getEnums();
+
+ binder.bind(new BeanWithEnums());
+ select.select(TestEnum.ONE);
+
+ assertEquals(Collections.singleton(TestEnum.TWO), enums);
+ }
+
@Test
public void bound_deselect_beanValueUpdatedToNull() {
item.setEnums(Collections.singleton(TestEnum.ONE));