pree pree - 1 month ago 10
Java Question

Get field descriptor in Protocol Buffers

Is there a way to get the field descriptor by using the given field number in protocol buffers? I know it exists for C++ (FindKnownExtensionsByNumber()) using reflection, however, I couldn't one for Java.


I suspect you're looking for Descriptor.findFieldByNumber. Note that will find a field by number, not an extension. For extensions, use ExtensionRegistry.findExtensionByNumber.