BindingsManager { public <S, D> void bindList(@NotNull ObservableList<D> destList, @NotNull ListExpression<S, D> srcExpression) { releaseList(destList); myListWrappers.add(new ListBindingWrapper(destList, new ListBinding<S, D>(destList, srcExpression))); } BindingsManager();  BindingsManager(InvokeStrategy invokeStrategy); void bind(@NotNull ObservableProperty<T> dest, @NotNull ObservableValue<T> src); void bind(@NotNull ObservableProperty<T> dest, @NotNull ObservableValue<T> src, @NotNull ObservableValue<Boolean> enabled); void bindTwoWay(@NotNull ObservableProperty<T> first, @NotNull ObservableProperty<T> second); void bindList(@NotNull ObservableList<D> destList, @NotNull ListExpression<S, D> srcExpression); void release(@NotNull ObservableProperty<?> dest); void releaseTwoWay(@NotNull ObservableProperty<T> first, @NotNull ObservableProperty<T> second); void releaseList(@NotNull ObservableList<T> destList); void releaseAll(); static final InvokeStrategy APPLICATION_INVOKE_LATER_STRATEGY; static final InvokeStrategy SWING_INVOKE_LATER_STRATEGY; static final InvokeStrategy INVOKE_IMMEDIATELY_STRATEGY; }
@Test public void mapBindingsUpdateDestinationList() throws Exception { BindingsManager bindings = new BindingsManager(BindingsManager.INVOKE_IMMEDIATELY_STRATEGY); ObservableList<Integer> numericList = new ObservableList<Integer>(); for (int i = 1; i <= 5; i++) { numericList.add(i); } ObservableList<String> stringList = new ObservableList<String>(); CountListener listener = new CountListener(); stringList.addListener(listener); bindings.bindList(stringList, new AbstractMapExpression<Integer, String>(numericList) { @NotNull @Override protected String transform(@NotNull Integer srcElement) { return srcElement.toString(); } }); assertThat(stringList).containsExactly("1", "2", "3", "4", "5"); assertThat(listener.getCount()).isEqualTo(1); numericList.addAll(Arrays.asList(6, 7)); assertThat(stringList).containsExactly("1", "2", "3", "4", "5", "6", "7"); assertThat(listener.getCount()).isEqualTo(2); numericList.clear(); assertThat(stringList).isEmpty(); assertThat(listener.getCount()).isEqualTo(3); }