Concatenated observable list
Michael Strauß
michaelstrau2 at gmail.com
Sat Dec 31 18:15:19 UTC 2022
FXCollections.concat(ObservableList...) can be used to create a new
ObservableList that contains the concatenation of all elements of the
source lists. This is useful to initialize the contents of the new
ObservableList, but the returned list is not kept in sync with the
source lists.
I'm proposing to add a new method:
FXCollections.concatenatedObservableList(ObservableList...)
Like FXCollections.concat, it returns a list that contains the
concatenation of all elements of the source lists. However, in this
case the returned list is unmodifiable and is always kept in sync with
the source lists. This can be useful to create a list where only parts
of the list are under the control of the author, and other parts are
derived from other lists.
I'm interested to hear your thoughts on this. Here's the proposed
specification of the new method:
/**
* Creates a new unmodifiable {@code ObservableList} that contains
* the concatenation of the contents of the specified observable lists.
* In contrast to {@link #concat(ObservableList[])}, the list returned from
* this method is updated when any of the source lists are changed.
*
* @param lists the source lists
* @param <E> the element type
* @return an {@code ObservableList} that contains the concatenation
* of the contents of {@code lists}
* @throws IndexOutOfBoundsException if the sum of the number of
* elements contained in all source lists exceeds
* {@link Integer#MAX_VALUE}
*/
@SafeVarargs
public static <E> ObservableList<E> concatenatedObservableList(
ObservableList<E>... lists)
More information about the openjfx-dev
mailing list