pree pree - 1 year ago 99
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.

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download