I would like to propose an enhancement to the java options for protoc. This enhancement would allow one to specify the java interface which the generated proto object will implement.
It would be very beneficial to be able to have the protoc generate code that would be implementing some signature interfaces in the Java world. Unlike Python or Ruby, where if the method exists on an object, you can call it, in Java the methods must be declared on the classes, so it makes it difficult to write methods that could take multiple types of objects which are of Protocol Buffers type without being able to mark them with an Interface. Just knowing that the object is of type "Message" is not sufficient. Imagine you have an interface Name defining a method getName(). Then I can have a bunch of protos defining various kinds of "names", like Person, City, Country, etc. All of those objects have a "name" field, and thus the getName() method. By marking them all with a 'Name' interface, I can then have my business logic code accept objects of 'Name' type as method arguments and be guaranteed that there is a "getName()" method on them. The problem with doing it the "reflection" route is that it does not guarantee me a compile-time checking and is not as clean and java-esque. The proposed syntax would be: message Person java_implement_interface = com.domain.Name; required string name; required int32 age; } Please post your thoughts, comments & objections... :) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/protobuf?hl=en -~----------~----~----~----~------~----~------~--~---
