Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting a Protocol Buffer to a POJO [closed]

Is there a tool or library that can map a Protobuff object to a POJO. I would like to have the pojo implement other interfaces that I can not with the ProtoBuff object. Or would I have to manually do this conversion?

like image 388
user2687319 Avatar asked Aug 15 '13 20:08

user2687319


2 Answers

Maybe too late, but you can try protobuf-converter library. It is easy to use.

Convert POJO object to related protobuf message:

POJOClass pojoInstance = new POJOClass();
...
ProtobufClass protoInstance = Converter.create().toProtobuf(ProtobufClass.class, pojoInstance );

Code for backward conversion:

POJOClass pojoInstance = Converter.create().toDomain(POJOClass.class, protoInstance);
like image 87
jsjem Avatar answered Sep 20 '22 13:09

jsjem


Take a look at ProtoStuff. I think it will do what you want.

I believe that you will want to use the "java-bean" compiler.

Edit: Changed the link.

like image 26
DwB Avatar answered Sep 20 '22 13:09

DwB