newBuilderForType: "Constructs a new builder for a message of the same
type as this message."

That's if you have a message, and you want to create a builder for
that type of message. Not what you want.

The actual types are outside of the library, and need to be looked up
via a type registry. I could have sworn there was such a thing, but
can't find it now. May be good to have a look through the generated
code, and see where it registers itself -- should give you a pointer.

Or you can maintain the registry yourself - a map of string -> default
instance for the type, from which you can call newBuilderForType().

  -ilia

On Mon, Jul 9, 2018 at 5:45 PM, John Lilley <whee...@gmail.com> wrote:
> Well, apparently I am really off base.  Given a Descriptor I cannot figure
> out how to create the right message. I *thought* this was the right
> approach:
>  Descriptors.Descriptor desc = // look up the descriptor
>  Builder builder = desc.toProto().newBuilderForType();
>  Message message = builder.mergeFrom(requestBytes).build();
>
>
> But no.  Can anyone help me with this?  I need to go from the full name of a
> message to its builder and I'm not finding anything like MessageFactory() or
> DescriptorPool in Java.
> Thanks
> john
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to protobuf+unsubscr...@googlegroups.com.
> To post to this group, send email to protobuf@googlegroups.com.
> Visit this group at https://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to