Add Extractor to Existing ObservableList

I have a model class ModelParentthat has an observable list ObservableList<ModelChild>, where ModelChildis another model class, with its own properties.

class ModelParent { 
    private final ObservableList<ModelChild> children = FXCollections.observableArrayList(); 

    public ObservableList<ModelChild> getChildren() {
        return children;
    }

    // More properties...
}

In some cases, I want an extractor to be applied to the list, that is, to be able to receive notifications when the list changes or a specific member of the list changes. The problem is that in different cases I want various properties to look, and sometimes I don’t care at all.

I know that I can apply an extractor to it ObservableListwhen I create it, but can I add an extractor to an existing list? Or perhaps create an observable list supported by the original (with changes reflected in both directions), but with an additional extractor?

, , , , . , , , ObservableList.

Java 8? ?

+4

Source: https://habr.com/ru/post/1622844/


All Articles