Not sure where to ask this. We used to have kotlin...
# getting-started
a
Not sure where to ask this. We used to have kotlin 1.4 and use mapstruct and the @KotlinBuilder annotation everywhere. But with kotlin 1.6 @KotlinBuilder doesn’t work anymore. What have people done to solve this? It seems like I don’t need it for the mapstruct per se anymore, but I’m finding myself changing all lists to mutable lists. As if Kotlinbuilder used to be able to get it working with lists but without it everything needs to be actually mutablelists. Does this sound familiar to anybody?
t
I never really used mutable list, it sounds a bit strange to me you have to change a lot. at least, the few occurrences we have of mutable lists are in private methods, never exposed publicly
Copy code
class SomeObj(val list: MutableList)
means someone could do
Copy code
val obj = SomeObj(aList)
obj.list.add(newElem)
which seems “wrong” to me. maybe you could share some examples of this need and there might be different pattern you could apply (never really saw a builder in the sense of java builder in kotlin either, typically named parameters are quite sufficient there)
r
Even with
class SomeObj(val list: List)
the user can still do
Copy code
Val list = mutableListOf(...)
val obj = SomeObj(list)
list.add(newElem)
t
true, there is always a limitation to how much you can protect yourself. and true as well that in the end you are the user in this case (unless you are writing a library)
a
Just for potential future reference, thank you for responding cause it made me think I had something else going on and eventually it turned out I had an old dependency messing everything up. Once you move up to kotlin 1.6 and mapstruct 1.5 you don’t need mapstruct-kotlin. Thank you both!