Make TransformationList (Filtered and Sorted) extendable
TobiasDiez at gmx.de
Sun Aug 16 13:28:25 UTC 2020
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
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.
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:
Looking forward to your feedback.
More information about the openjfx-dev