Annotation Type ShallowImmutable


@Retention(CLASS) @Target(TYPE) @Documented public @interface ShallowImmutable
A class is considered ShallowImmutable when:
  • All fields are final and cannot be reassigned
  • The class does not mutate its internal state after construction (e.g., it does not modify collections or mutable objects held in its fields)
  • Objects referenced by the fields may be mutable and can be modified externally

Warning: Shallow immutability does not guarantee thread safety. If referenced objects are mutable, external modification can lead to unpredictable behavior in concurrent environments.

This annotation is for documentation purposes only and does not enforce or verify immutability.

Since:
4.1.0
See Also: