-
Notifications
You must be signed in to change notification settings - Fork 656
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
Make generateModelBuilder generate deep builders (instead of shallow) #680
Make generateModelBuilder generate deep builders (instead of shallow) #680
Conversation
cc: @martinbonnin |
86e3163
to
34e3c18
Compare
Just to let you know I started looking into this but I have troubles importing the snapshot into my project. Also it would help to have an integration test where we could demonstrate the usage of this. Not really sure how to do this without adding another submodule as it requires changing some compiler flags. Anyways, I'll post again when I get it working |
* | ||
* @param <T> the type of the input to the operation | ||
*/ | ||
public interface Consumer<T> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you use Consumer on purpose ? Why not call the class Mutator or BuilderMutator so as to avoid confusion with the other Consumers (reactivex, java.util, com.annimon.stream, maybe others ?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just copied from Java8, but yeah we can rename it
For each builder generate additional setter with `Consumer<*.Builder>` as an argument: ``` public Builder hero(@nonnull Consumer<Hero.Builder> mutator) { Hero.Builder builder = this.hero != null ? this.hero.toBuilder() : Hero.builder(); mutator.accept(builder); this.hero = builder.build(); return this; } ``` That will allow user to do next: ``` data.toBuilder() .hero(someHero) // or .hero(new Consumer<>() { void accept(Hero.Builder builder) { builder.name("Joe") .age(31) } }) ``` This will be even better with lambda support: ``` data.toBuilder() .hero(someHero) // or .hero(builder -> builder .name("Joe") .age(31) } }) ``` Closes apollographql#643
34e3c18
to
c606d30
Compare
For each builder generate additional setter with
Mutator<*.Builder>
as an argument:That will allow user to do next:
This will be even better with lambda support:
Closes #643