Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModelWrapper with methods field / immutableField that accept arguments of type Set and Map #531

Closed
johandeschutter opened this issue Nov 23, 2017 · 2 comments

Comments

@johandeschutter
Copy link

Hello,

Is possible to add to the ModelWrapper class the methods field / immutableField that accept arguments of type Set and Map .

Currently only the methods field / immutableField only accept collections of type List.

Something like this:
public SetProperty field(SetGetter<M, E> getter, SetSetter<M, E> setter) {
return add(new BeanSetPropertyField<>(this::propertyWasChanged, getter,
(m, set) -> setter.accept(m, FXCollections.observableSet(set)), SimpleSetProperty::new));
}

public <E> MapProperty<E> field(MapGetter<M, E> getter, MapSetter<M, E> setter) {
    return add(new BeanMapPropertyField<>(this::propertyWasChanged, getter,
            (m, map) -> setter.accept(m, FXCollections.observableMap(map)), SimpleMapProperty::new));
}

Regards,

Johan

@manuel-mauky
Copy link
Collaborator

Hi johandeschutter,
thanks for your request. At the moment this is not possible but it could be added. I don't see a reason why this would not work. It's missing because we hadn't had the need for this yet and based on my experience not many people are using SetProperty and MapProperty.

I don't know when I find the time to add this feature. However, I'm happy to accept a PullRequest for this. Thinks to do are:

  • Add getter/setter interfaces (MapGetter, MapSetter...)
  • Extend the example classes for the tests (Person.java, PersonFX.java and PersonImmutable.java)
  • Extend the unit tests in ModelWrapperTest.java
  • Implement the feature in ModelWrapper.
    • Add *Field classes like BeanListPropertyField for Map and Set.
    • Implement overloaded field methods similar to the code you've already posted.

@manuel-mauky
Copy link
Collaborator

I've implemented the first part of this issue: You can now use Sets with the Model-Wrapper.
I will add support for Maps within the next days. It works the same way

manuel-mauky added a commit that referenced this issue Dec 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants