From some API call, I am getting back an IObservableList<E>, from the Eclipse Databinding framework. I'd wish to derive another IObservableList<E> from this one according to some predicate defined on the element type E. The derived list should be dynamically updated according to changes in the original list.
How can I best implement that? I've considered subclassing DecoratingObservableList, but couldn't figure out how to use it.
Of course, I could implement myself the whole IObservableList interface, but I was wondering if there were not other utility classes around that I could use.
I think extending
DecoratingObservableListis a good start. I would also suggest concentrating on exactly the intended usage instead of immediately implementing the entire API. For example, do you need random-acces writing viaset? If not, then don't bother implementing it. This covers a read-only view of a mutableObservableList, mapping the change events of the decorated list to the appropriate change events on the filtered list: