-
Notifications
You must be signed in to change notification settings - Fork 3
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
Implement support for property builders #80
Conversation
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.
I'm not sure how close to the original you want to fly here - what you have will work for existing implementations, but will behave differently than AutoValue if users make calls in the wrong order.
We're also missing the chained builder calls from the docs:
Edit: I suppose the remainingMethods
TODOs will solve the chained builder calls, since those aren't generated anyway.
} | ||
|
||
internal fun requiredBuildableCollection(`value`: ImmutableList<String>): Builder = | ||
apply { this.requiredBuildableCollection = `value` } |
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.
This implementation doesn't match the docs - I think we need to check if the member is null first:
The same caller can mix the two styles only in limited ways; once foosBuilder has been called, any subsequent call to setFoos will throw an unchecked exception. On the other hand, calling setFoos first is okay; a later call to foosBuilder will return a builder already populated with the previously-supplied elements.
Like this:
@Override
public FakeComment.Builder reactions(ImmutableList<Reaction> reactions) {
if (reactions == null) {
throw new NullPointerException("Null reactions");
}
if (reactionsBuilder$ != null) {
throw new IllegalStateException("Cannot set reactions after calling reactionsBuilder()");
}
this.reactions = reactions;
return this;
}
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.
oooo good catch, let me update
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.
for chained builders - isn't the doc saying to manually write those and just hide the abstract builder method? |
Resolves #79