Make TransformationList (Filtered and Sorted) extendable
Tobias Diez
TobiasDiez at gmx.de
Sun Aug 16 13:28:25 UTC 2020
Hello everybody,
Right now it is hard to extend the FilteredList and the SortedList as these
classes are marked final. This makes it practically impossible to add
convenient helper methods, or change or extend the behavior of these
classes.
I agree that normally you don't need to extend them, but I also don't see
any reason why you shouldn't be allowed to do so.
Usually, you could use composition over inheritance if a class is marked
final but you still want to extend it. However, some of the controls expect
really a SortedList , e.g.
https://github.com/openjdk/jfx/blob/master/modules/javafx.controls/src/main/
java/javafx/scene/control/TableView.java#L442
So this approach does not work either.
The motivation for me comes from some limitations that we encountered while
developing EasyBind, a small library to make bindings easier. We provide a
few convenient methods that extend the ObservableList, and we want to
provide a fluent interface similar to streams, e.g.
EasyBind.wrap(standard observable list).filter(predicate).map(mapper).
For this to work, the filter method needs to return a FilteredList with the
additional map method. The easiest solution would be to derive from
FilteredList, and implement the "EasyObservableList" interface that we have.
Removing the final keyword is done in the following PR:
https://github.com/openjdk/jfx/pull/278
Looking forward to your feedback.
Best regards
Tobias
More information about the openjfx-dev
mailing list