Hacker News new | ask | show | jobs
by JamesFM 3193 days ago
I have been coding in Kotlin and using the interopt for various libraries. Typically you want to model things interacting with what Kotlin calls “platform types” as nullable.

So for JPA entities, each field is marked as nullable, because in Java it is. If we need a null checked version we map it from the nullable fields object to a object that has been null checked and has non-nullable fields (where appropriate).

Wrappers can be written to interact with more traditional Java libraries that do a similar null check and mapper, keeping platform types from propergating intro other layers of the system.

Platform types make interopt way easier, but if you are concerned with null safety you have to write some code to deal with them.