@ImmutableValue Specification

This annotation declares that instances of this class are immutable and are value objects.

That is, In object-oriented and functional programming:

Immutability Contract

This class declares the immutability contract, which is then checked by the JPure compile-time checker.

What Qualifies As An Immutable Value?

Various classes from the Java platform are already immutable, and recognized as such by Pure4J.

Notable Exceptions To Immutable Values

Implementing toString() and HashCode()

Clients are warned that toString and hashCode are not pure functions, as they are not deterministic (being dependent on the system hash code, which is based on object id).

Implementing equals()

equals() by default is pure.

Your code is expected to observe the contract of equals() and not modify the state of the parameter object being passed to it. Unfortunately, this case is not checked by the system.

Exceptions

Exceptions are regarded as being immutable for convenience only. You should not use exceptions for passing system state.

Extending / Using Other Code

Pure4J will check code in your code base, but assume that anything tagged @ImmutableValue in a library has been correctly verified by the build process of that library.