Skip to content

Usage with JavaFX Beans #640

Answered by armandino
Sheikah45 asked this question in Q&A
Jun 15, 2023 · 3 comments · 9 replies
Discussion options

You must be logged in to vote

@Sheikah45 yes, this is the intended usage. Previously, Instancio only supported setters that have a matching field. Since v4 it can invoke setters that have no matching field using the Keys.ON_SET_METHOD_UNMATCHED setting, as you've done in the sample project. This makes it possible to populate classes like:

class Person {
    private final Map<String, String> attributes = new HashMap<>();

    String getFavouriteFood() {
        return attributes.get("FAVOURITE_FOOD");
    }

    void setFavouriteFood(String favouriteFood) {
        attributes.put("FAVOURITE_FOOD", favouriteFood);
    }
}

The Keys.ON_SET_METHOD_UNMATCHED is marked as an experimental API since it's new behaviour, but it …

Replies: 3 comments 9 replies

Comment options

You must be logged in to vote
2 replies
@Sheikah45
Comment options

@Sheikah45
Comment options

Comment options

You must be logged in to vote
2 replies
@Sheikah45
Comment options

@armandino
Comment options

Comment options

You must be logged in to vote
5 replies
@armandino
Comment options

Answer selected by Sheikah45
@Sheikah45
Comment options

@armandino
Comment options

@Sheikah45
Comment options

@armandino
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants