DEV Community

Discussion on: 🎩 Immutability in Java 🔥 Made Easy

 
cchacin profile image
Carlos Chacin ☕👽

I'm actually recommending to use the immutables library instead of lombok, that library generates code and does NOT include any runtime dependency to the classpath/modulepath.

You are right about the Date and List data types in the example, those are actually intentional to demonstrate that we have to take care of those things when we want to write immutable objects by hand. The immutable library takes care of the Collections situation creating copies, unfortunately the only way of fix the Date issue is using another alternative like java.time.LocalDate

if you have the time please take a look to this post as well and any feedback would be helpful: