Extract all possible field paths from Java Protocol Buffers
I have a set of complied Java Protocol Buffers. I need to extract all possible fields from it, can I do it w/o knowing structure of a Protocol Buffer in advance?
Imagine I have a message
message Person { required string name = 1; required int32 id = 2; optional string email = 3; enum PhoneType { MOBILE = 0; HOME = 1; WORK = 2; } message PhoneNumber { required string number = 1; optional PhoneType type = 2 [default = HOME]; required PhoneLocation location = 3; } repeated PhoneNumber phones = 4; } message PhoneLocation { required string name = 1; }
I need something that will print for me ([*] stands for repeated field)
Person.name Person.id Person.email person.phones[*] person.phones[*].number person.phones[*].type person.phones[*].location.name
I have only java class, how can I do it?