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

Request: implement/add ExtensionRegistry.isEmpty() in Java #52

Closed
protobufel opened this issue Oct 15, 2014 · 3 comments
Closed

Request: implement/add ExtensionRegistry.isEmpty() in Java #52

protobufel opened this issue Oct 15, 2014 · 3 comments

Comments

@protobufel
Copy link

It is crucial to know whether an ExtensionRegistry is empty - for a number of reasons; but impossible at the moment. It could have been produced as ExtensionRegistry.getEmptyRegistry(), or as the result of ExtensionRegistry.newInstance(), or ExtensionRegistry.newInstance().getUnmodifiable(), and so forth.
However, there is no access to the underlying map, or its length, and also there is no equals.

@xfxyjwf
Copy link
Contributor

xfxyjwf commented Oct 15, 2014

Can you expand on the reasons to check whether an ExtensionRegistry is empty?

@protobufel
Copy link
Author

Use case, one of many: you have a nonnull field, parameter of type
ExtensionRegistry, empty registry would be its null-token. How then you
recognize it later? The registry could be also empty as described earlier.

Or you've got a registry value, and if it is empty you do nothing,
otherwise some processing, for example, reparsing/deserialization.

The feature is safe, and doesn't break anything!
On Oct 14, 2014 7:16 PM, "Feng Xiao" [email protected] wrote:

Can you expand on the reasons to check whether an ExtensionRegistry is
empty?


Reply to this email directly or view it on GitHub
#52 (comment).

feyr666 pushed a commit to wolf34736/protobuf that referenced this issue Apr 23, 2015
@xfxyjwf xfxyjwf added the java label Jan 20, 2016
@haberman
Copy link
Member

haberman commented Mar 7, 2017

This feature request is very old. I don't think in general we attempt to give every type an empty/null value that is recognizable. If you want a value to be possibly absent, it seems to make more sense to just make it nullable, instead of making it nonnull but having an "empty" value.

@haberman haberman closed this as completed Mar 7, 2017
TeBoring pushed a commit to TeBoring/protobuf that referenced this issue Jan 19, 2019
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

3 participants