Closed 313hemant313 closed 10 months ago
Can you elaborate on this? I'm not sure I understand your use case.
In proto Enums as Map Keys support is not available. https://github.com/protocolbuffers/protobuf/issues/7791
Wanted to check if somehow we can add some extra code to make this happen.
That linked issue did a pretty good job of explaining why enum map keys were not implemented in protobuf core.
How would you propose dealing with a map of enum keys in Java, when the client can send keys that are not understood by the server?
In theory, you could build a code generator with jProtoc to emit Java helper classes for working with maps keyed by integers that correspond to enums, but you would have to place difficult constraints on contract evolution.
I was thinking to create a Any type field in proto and will disable getters and setters. Using jProtoc will add Any to EnumMap getter and setters.
For keys that are not understood will be mapped to maybe NOT_SUPPORTED enum value.
@rmichela Do you think if above will be possible with jProtoc ?
I don't believe so. JProtoc can or change the behavior of the default proto compiler.
Can any one please help with sample code to make a proto generated class implement any interface ?
Wanted to check if anyone has tried some modification to generated java classes to add Enum key support in proto map.