Right ... I'm lazy too ...
add("FooType", FooType.getDefaultInstance())
...
map.get("FooType").newBuilderForType().mergeFrom(bla).build()
Right?
On Mon, Jul 9, 2018 at 8:45 PM, John Lilley wrote:
> Because I am lazy! I only want to add the wrapper once.
> john
>
> --
> You received this mess
Because I am lazy! I only want to add the wrapper once.
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
Why not just call add() with a Message instance instead?
On Mon, Jul 9, 2018 at 7:39 PM, John Lilley wrote:
> Darn, there's only one snag. I need the protobuf package name, not the java
> package classname, in order to construct the message name that corresponds
> to the result of full_name() in
Darn, there's only one snag. I need the protobuf package name, not the
java package classname, in order to construct the message name that
corresponds to the result of full_name() in the C++ generated code. Of
course, I can *make *them the same thing, but I'm not finding any way to
interrogate th
Success! This works nicely (although, lacking polish)
public class MessageFactory {
private final Map defaultMessages = new HashMap<>();
public void add(Class wrapperClass) {
for (Class nestedClass : wrapperClass.getDeclaredClasses()) {
if (!Message.class.isAssignable
Feng,
Thanks so much. At least I know that what I'm looking for doesn't exist.
I am researching a variant of (1) that uses reflection on generated package
classes to build a fullname->Message map. Once I have a Message I can ask
for a builder and be on my way. So I'll call getDefaultInstance() vi
On Mon, Jul 9, 2018 at 2:45 PM John Lilley 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.toP
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 co
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.merge
I see this in Descriptors:
public Descriptor findMessageTypeByName(String name) {
// Don't allow looking up nested types. This will make optimization
// easier later.
if (name.indexOf('.') != -1) {
return null;
}
if (getPackage().length() > 0) {
na
10 matches
Mail list logo