Examining a protobuf message - how to get field values by name?

后端 未结 1 601
醉酒成梦
醉酒成梦 2021-02-12 06:20

I seem unable to find a way to verify the value of a field inside a protobuf message without explicitly invoking its getter.

I see examples around that make usage of

1条回答
  •  太阳男子
    2021-02-12 06:55

    I am not sure you are looking for Descriptors#findFieldByName(name). You can try with followings:

    FieldDescriptor fieldDescriptor = message.getDescriptorForType().findFieldByName("fieldXyz");
    Object value = message.getField(fieldDescriptor);
    

    0 讨论(0)
提交回复
热议问题