-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add support for Nullable on Optional property builders #353
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
Add support for Nullable on Optional property builders #353
Conversation
5fa891f
to
3631f76
Compare
Any plans on merging this in the near future? |
I'm reworking other aspects of builders at the moment but I will look into this when I am done. |
3631f76
to
0d09533
Compare
I've just rebased onto the latest |
d19bb33
to
6a9bfe5
Compare
It's been updated again to handle the latest changes. |
It looks as if there's still a test failure. I'm hoping to cut AutoValue 1.4 soon, but I will look at this and #444 once that is done. Thanks for putting in the work to put them together! |
Meanwhile, can I ask that you add test code to AutoValueTest in this PR and the other one? |
Let me know if you would like any other test cases for this PR. |
00e3251
to
365b1c7
Compare
Is it planned to merge this PR in the near future? |
Any activity happening on this? Has this been superseded by something else? |
I'm surprised this hasn't been merged yet. What is the delay (apart from the conflicts which keep getting fixed)? |
I'd also love to see this feature get merged. It's really my only complaint with AutoValue -- right now the workaround (creating two versions of every builder method where you want to allow passing null) is very tedious. |
365b1c7
to
824568f
Compare
I've just fixed up this PR to match |
677a905
to
99438ae
Compare
Sorry to have dropped the ball on this. I've put together a modified version of this change and am sending it out for internal review. Thanks, @kenzierocks! |
…th a @nullable parameter. This is based on #353 by Kenzie Togami. Closes #353. RELNOTES: Allow an Optional property to be set in a builder through a method with a @nullable parameter. NOTE: As a side-effect of this change, a setter for a @nullable property must have its parameter also marked @nullable. Previously, if the @nullable was not a TYPE_USE @nullable, it was copied from the getter to the parameter of the generated setter implementation. For TYPE_USE @nullable it was already necessary to mark the setter parameter @nullable. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=195471227
…th a @nullable parameter. This is based on #353 by Kenzie Togami. Closes #353. RELNOTES: Allow an Optional property to be set in a builder through a method with a @nullable parameter. NOTE: As a side-effect of this change, a setter for a @nullable property must have its parameter also marked @nullable. Previously, if the @nullable was not a TYPE_USE @nullable, it was copied from the getter to the parameter of the generated setter implementation. For TYPE_USE @nullable it was already necessary to mark the setter parameter @nullable. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=195471227
This allows an
@Nullable
annotation to exist on aBuilder
property setter for anOptional
property, like so:Builder bar(@Nullable String bar);
. It usesofNullable
/fromNullable
to convert the value to the correctOptional
instance.This PR also replaces the logic in the(Edit: This doesn't work withBuilder
property getters to useofNullable
/fromNullable
instead of anif ($p == null)
check.Optional
primitives + wrapper classes.)This solves my request here: #278 (comment), and #384.