|
|
|
|
|
by rlmw
4505 days ago
|
|
There has been a lot of discussion on this kind of thing. One of the proposals for value types is to have them be immutable. As to what to do in the meantime - I would suggest that you use either findbugs' immutability detection or Graham Allen's Mutability Detector: https://github.com/MutabilityDetector/MutabilityDetector. Findbugs picks up an @Immutable annotation and checks whether this is the case, whilst Mutability Detector allows you to assert that classes are immutable as part of your unit tests. I appreciate its not as good as language support, but it is better than relying on an unchecked convention. |
|