posted 8 years ago
I recently found out that I can assign non-null defaults to classes annotated with @Immutable as so:
And tests seem to show that this works fine, which is awesome (and appears to be undocumented). However, I want to go even further: I want to make object construction either throw an exception or generate a compiler error if certain properties are not set in the constructor. In other words, I want to mark some properties as required, so they have to be given an explicit value during construction. Is this possible within @Immutable? I would prefer to reduce boilerplate code at all costs.