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: Ie2f15eb626dd80df2036bcb2d4e9387fc31389c9tags/8.0.0.alpha3
@@ -71,7 +71,7 @@ public class CheckBoxGroup<T> extends AbstractMultiSelect<T> { | |||
@Override | |||
public Set<T> getSelectedItems() { | |||
return Collections.unmodifiableSet(selection); | |||
return Collections.unmodifiableSet(new LinkedHashSet<>(selection)); | |||
} | |||
@Override |
@@ -117,6 +117,20 @@ public class BinderMultiSelectTest | |||
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)); |