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

Builder methods for adding individual items to collection and map properties #100

Open
cjkent opened this issue Jan 14, 2015 · 0 comments
Open
Labels

Comments

@cjkent
Copy link
Contributor

cjkent commented Jan 14, 2015

For example, say we have a bean Foo with a property List<String> names and a map property Map<String, String> attributes.

I'd like to be able to do this:

Foo foo = Foo.builder()
    .addNames("name1")
    .addNames("name2")
    .putAttributes("attr1", "val1")
    .putAttributes("attr2", "val2")
    .build();

This makes for much cleaner code than creating a map or list externally in order to pass it to the builder.

It would be even better if the methods could use the singular, e.g. addName or putAttribute but that's probably a lot to ask and not crucial.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants