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

Use java boxed types when setting well known types #2055

Closed
jhspaybar opened this issue Sep 1, 2016 · 5 comments
Closed

Use java boxed types when setting well known types #2055

jhspaybar opened this issue Sep 1, 2016 · 5 comments

Comments

@jhspaybar
Copy link

jhspaybar commented Sep 1, 2016

I would like the functionality that using things like Int32Value, Int64Value, StringValue, BoolValue, etc would allow for using setters of the form setFoo(Integer), setFoo(Long), setFoo(String), setFoo(Boolean) where a passed null will essentially no-op, but a value would call the XYZValue.newBuilder.setValue(arg), but that on the getter side of things the interactions still have hasFoo() and getFoo().getValue() to access the data. Given that the return type can't be type parameterized easily in Java, this seems like a good place to start, possibly with discussion as to whether there should be getters of the form getNullableFoo() or getOptionalFoo that gets generated.

If this is something that would be helpful to others(I think it would) I'd be happy to contribute a pull request that at least makes these changes to the setter side of things with further discussion for proper use on the getter side.

@jhspaybar
Copy link
Author

@xfxyjwf I'm interested in contributing this if it's desirable. Should I just open a pull request? I didn't want to do the work if it would be a rejection no matter what for some reason.

@xfxyjwf
Copy link
Contributor

xfxyjwf commented Sep 9, 2016

The proposal sounds good to me, but API changes like this require a Java API review. It's Google internal and we don't currently have a way for external contributors to participate. If you are interested in helping make this change, can you create a Google doc describing the proposal? I can take it to the review committee on your behalf.

@jhspaybar
Copy link
Author

I will write that up! Do you have a template I should follow?

@xfxyjwf
Copy link
Contributor

xfxyjwf commented Sep 10, 2016

There isn't any publicly available template as far as I know. I think you can just write it in your preferred format and I'll comment if it's missing anything needed for the API review.

@xfxyjwf
Copy link
Contributor

xfxyjwf commented Jun 8, 2018

We did a Java API review for this and a new wrapper types API was added to improve the usability. You can now do:

builder.setFoo(Int32Value.of(1234));

@xfxyjwf xfxyjwf closed this as completed Jun 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants