No, the camel-case name is not stored anywhere.  You will need to construct
it yourself.  If performance is a concern, just cache the results in a
Map<FieldDescriptor, String>.

On Wed, Dec 29, 2010 at 8:11 AM, Sean Nguyen <[email protected]> wrote:

> I am writing a utility base on your suggestion and I run into a
> problem of getting a camel name out of a  FieldDescriptor.
>
> My proto message is like this:
>
> message Person
> {
>
> optional string last_name = 1;
> optional string first_name = 2;
>
> }
>
>
> When java object is generated it uses camel field name as lastName,
> firstName. Is there a way to get the camel field name out? I don't
> want to get the original field name name : last_name, first_name and
> convert it again to camel field name every time that I want to do
> getter and setter on java pojo (very inefficient).
>
>
> Thanks,
>
>
> On Dec 28, 5:16 pm, Kenton Varda <[email protected]> wrote:
> > I don't know of any existing tools for this.  You could write code that
> does
> > this via reflection (protobuf reflection on the protobuf object, and
> basic
> > java reflection on the POJO).  Or, you could write a protoc plugin which
> > generates the code you need, though that will be a lot more complicated.
> >
> > On Tue, Dec 28, 2010 at 3:55 PM, Sean Nguyen <[email protected]>
> wrote:
> > > Hi,
> >
> > > I have a protocol buffer object like:
> >
> > > message PBPerson
> > > {
> > > optional string lastName = 1;
> > > optional string firstName = 2;
> > > }
> >
> > > I also have another java object
> >
> > > class JavaPerson
> > > {
> > > private String lastName;
> > > private String firstName;
> >
> > > // setter and getter
> > > }
> >
> > > I want to convert from PBPerson to JavaPerson and vice versa and I
> > > don't want to do it manually by writing getter and setter for each
> > > fields because my object can have more than 10 fields. Is there a
> > > utility from protocol buffer that helps me doing that. So the would
> > > expect a utility class that does something like:
> >
> > > JavaPerson javaPerson = PBConverter.convert(PBPerson pbPerson);
> >
> > > PBPerson pbPerson = PBConverter.convert(JavaPerson javaPerson);
> >
> > > Thanks,
> >
> > > --
> > > 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]<protobuf%[email protected]>
> <protobuf%[email protected]<protobuf%[email protected]>
> >
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/protobuf?hl=en.
>
> --
> 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]<protobuf%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/protobuf?hl=en.
>
>

-- 
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.

Reply via email to