Hi, looking at inline classes now. In our codebase...
# announcements
c
Hi, looking at inline classes now. In our codebase we have
typealias Amount = BigDecimal
to mark amounts which have proper scaling and rounding. It serves well as a markier, but unfortunately doesn't help with compile time checking. I wonder if I can instead use inline classes. The problem is there is a lot of jackson mapping and JPA Hibernate mapping going on in the application. So I wonder will inline classes "just work" with all this mappinng?
j
If they’re nullable, you’ll probably fall into the problem described in this issue that I filed some time ago: https://github.com/FasterXML/jackson-module-kotlin/issues/199
It’s been a while since I played with them though, so maybe the fact that you’re using a non-primitive BigDecimal as the inlined class won’t cause any problem.
I can’t remember if I played with Hibernate, but since the compiler replaces the inline class by the actual one, I guess Hibernate shouldn’t even see a difference.
I realize this doesn’t really answer your question 🙂. But anyway, I would be very happy to have your conclusions if you make some tests.