Knut Arne Vedaa
knut.arne.vedaa at broadpark.no
Wed Jan 2 14:00:40 PST 2013
Context: I'm working on an implementation of a FilteredList (in Scala).
(It's less trivial than I thought. :))
> public final ObservableList<? extends F> getDirectSource();
> // The first non-transformation list in the chain.
> public final ObservableList<?> getOriginalSource();
> // Maps the index of this list's element to an index in the direct
> source list.
> public abstract int getSourceIndex(int index);
> public final int getOriginalSourceIndex(int index);
What do you see as the use-cases for having the above methods publicly
> public final TransformationList<E, E> filtered(Predicate<? super E>
> public final TransformationList<E, E> sorted(Comparator<? super E>
Why do these return TransformationList instead of FilteredList and
Is it possible (or desired) to be able to swap out the the predicate and
comparator dynamically, i.e. having them as properites on FilteredList
and SortedList respectively? If not, would you have to call e.g.
refilter() manually when you want to change the predicate?
> ObservableList<E> interface would get a new defender method:
> public TransformationList<E, E> transform();
> this would return TransformationList representation of the current list.
> Another appoach would be to have filtered(), sorted() directly on
> ObservableList as a defender methods, which would remove the necessity
> of calling transform() before filtered()/sorted(), but I find the first
> one more consistent with JDK API.
From an API point of view, having filtered and sorted on ObservableList
would make most sense IMO.
(Then again, that would exclude the possibility of having an alternative
implementation of ObservableList that has a filtered() method that
returns a "filtered list" that is not necessasarily compatible with
JFX's FilteredList. Unless you made the latter an interface, in which
case alternative implementations could implement that as well...)
Knut Arne Vedaa
More information about the openjfx-dev