RFR: 8091429: ObservableList<E>#setAll(int from, int to, Collection<? extends E> col) [v2]

John Hendrikx jhendrikx at openjdk.org
Mon Oct 20 05:06:20 UTC 2025


> This PR implements two new default methods on `ObservableList` to be able to replace elements at a given position or within a specified range.
> 
> Justification for this change is to allow an `ObservableList` to be bulk modified resulting in a single `ListChangeListener` call back.  In this way the callbacks don't observe the list changing its size from S to S-X back to S again(*). Currently the only way to bulk replace a range of items is to remove X items then add X items, resulting in two listener callbacks in between which the size of the list can be observed to change.
> 
> The other alternative is to call `set` individually for each item, which results in many change notifications.
> 
> With the addition of this PR, and the changes in `ModifiableObservableListBase`, replacing a range of items becomes a single change callback.
> 
> (*) The list may indeed change size still as plain `List` does not have `setAll` operations; size listeners may observe this, but it will no longer be observable from a `ListChangeListener` due to multiple separate callbacks.

John Hendrikx has updated the pull request incrementally with two additional commits since the last revision:

 - Fix test
 - Rename setAll to replaceRange and removed superfluous method

-------------

Changes:
  - all: https://git.openjdk.org/jfx/pull/1937/files
  - new: https://git.openjdk.org/jfx/pull/1937/files/776dd9aa..0b42426b

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jfx&pr=1937&range=01
 - incr: https://webrevs.openjdk.org/?repo=jfx&pr=1937&range=00-01

  Stats: 47 lines in 3 files changed: 0 ins; 38 del; 9 mod
  Patch: https://git.openjdk.org/jfx/pull/1937.diff
  Fetch: git fetch https://git.openjdk.org/jfx.git pull/1937/head:pull/1937

PR: https://git.openjdk.org/jfx/pull/1937


More information about the openjfx-dev mailing list