Immutable encapsulations
Sometimes it's necessary to prevent changing data of an encapsulation. Immutable encapsulations must be initialized with data in their constructor. Afterwards data cannot be changed.
Immutable ArrayEncapsulation
Immutable ArrayEncapsulations can hold any data without restriction.
Immutability in your own encapsulation
Each encapsulation class you create on your own can be immutable regardless wether it's an ArrayEncapsulation or a PropertyEncapsulation or something else.
Each encapsulation inheriting from AbstractEncapsulation
can be checked about their mutability:
Immutable containers
There is also a class of an immutable container which prevents changing it's elements.
Last updated