Hi guys. In our project there is a lot of boilerpl...
# server
a
Hi guys. In our project there is a lot of boilerplate code and I am considering migrate to Kotlin. However we have 3 layers of model classes (ATO, actual model, DTO) and therefore we use mappers heavily (with complex composition structure). For now we use Remap but it is not working too well with Kotlin. I was considering to switch to MapStruct but it is also not supporting the Kotlin directly. There is a library to create builders automatically but it is rather simple and not supported anymore. What do you think would be the best solution here? Manual mapping, MapStruct or something else?
m
MapStruct has a Kotlin example that I found. It may or may not help. https://github.com/mapstruct/mapstruct-examples/tree/master/mapstruct-kotlin
a
@Mitchell Syer thanks, I have seen that. In this example all fields are nullable. Probably it is forced. So we loose some of the Kotlin strong advantage.
m
I tried to use http://modelmapper.org/ with Kotlin some months back, but it didn’t work so we had to do it manually. Probably the structures were too complex and divergent from the library capabilities (Java code generated from gRPC protobufs, construction only through buiders). I gave up after trying this so I never gave a shot to the other Java mappers, but I would love to find one that has decent Kotlin support.
👍 1