Protobuf - Java POJO conversion

Skip to first unread message

Justin Morris

Jul 30, 2021, 3:24:03 AM7/30/21
to modelmapper
Hi Everyone

I've run into an issue converting a Protobuf generated class to a POJO.

The Protobuf class is an inner class of an inner class, with 4 string fields, all in snake case.

The POJO has the same four fields, all in camel case, and has the @Data and @Builder annotations present.

I have attempted so far:, DestClass)
modelMapper.typeMap(SrcClass, DestClass).addMappings(mapper -> {/*mappings*/})

The first doesn't map any data.
The second produces an error

1) Cannot map final type com.package.ProtobufRootClass$ProtoBufInnerClass

This is likely due to the generated classes all being 'final'.

I am using modelmapper-protobuf 2.4.4, with maven.
I have registered the ProtobufModule with the mapper after instantiation.

Is anyone aware of another way I might accomplish mapping the protobuf message to POJO, and visa versa.

Thank you in advance, and sorry for the trouble.

Reply all
Reply to author
0 new messages