public static Message createMessage(String messageName) {
FileDescriptor dps = Addressbook.getDescriptor();
System.out.println(dps.getPackage());
Descriptor dp = dps.findMessageTypeByName(messageName);
...
return null;
}
by the messageName I have got the Descriptor
You would need to list out all the message types you want to use, and
maintain a map from their Descriptor to their default instance (accessible
with getDefaultInstance()). You can then call newBuilder or other
construction methods.
If you are ok with using a dynamic rather than generated message