// my .proto
syntax = "proto3";import "google/protobuf/any.proto";
message CommandListPrinters {}
message Commands {
int32 id = 1;
repeated google.protobuf.Any command = 2;}
// my.java
CommandListPrinters commandListPrinters =
CommandListPrinters.newBuilder().build();Any any =
Any.newBuilder().setValue(commandListPrinters.toByteString()).build();Commands.Builder
commandsBuilder = Commands.newBuilder().setId(0);
commandsBuilder.addCommand(any);Commands commands =
commandsBuilder.build();//byte [] ba = commands.toByteArray(); Commands
cmds2 = Commands.parseFrom(ba);for (Any any2 : cmds2.getCommandList()) {
Descriptor fe = any2.getDescriptorForType();
// This IF is FALSE;
if (fe.equals(CommandListPrinters.getDescriptor()) ) {
CommandListPrinters cmdLR =
CommandListPrinters.parseFrom(any2.getValue());
}
}
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.