toImmutable

Converts the current PersistentDataContainer instance to an immutable implementation.

This method creates a specialized immutable representation of the container, depending on its size and structure:

  • Returns EmptyPersistentDataContainer if the container is empty.

  • Creates a SingletonPersistentDataContainer if the container contains exactly one key-value pair.

  • Constructs a PersistentDataContainerImpl for containers with more than one key-value pair.

Note: This operation ensures the resulting container is immutable, preventing further modifications.

Return

A PersistentDataContainer representing the immutable version of this container. The type of the returned instance depends on the size of the original container.

Author

Fantamomo

Since

1.0-SNAPSHOT