Hello everyone, I was curious what people think about introducing/using the Immutables <https://immutables.github.io/> library in Iceberg. The Immutables library (Apache License 2.0) works via annotation processing, where an abstract value class is annotated with *@Value.Immutable* to generate an *immutable implementation class*.
The main motivation for the Immutables library is outlined below: - Use true immutable objects that are type-safe, thread-safe, null-safe - Get builder classes for free - reduce amount of boiler-plate code - Get JSON serialization/deserialization for free (this will also be helpful for the REST-based Catalog <https://github.com/apache/iceberg/pull/3424>) since Immutable objects are serialization ready (including JSON and its binary forms) - Supports lazy, derived and optional attributes - Immutable objects are constructed once, in a consistent state, and can be safely shared - Will fail if mandatory attributes are missing - Cannot be sneakily modified when passed to other code - Immutable objects are naturally thread-safe and can therefore be safely shared among threads - No excessive copying - No excessive synchronization - Object definitions are pleasant to write and read - No boilerplate setter and getters - No IDE-generated hashCode, equals and toString methods required. However, custom implementation for these methods can still be written I did a small PoC in #3688 <https://github.com/apache/iceberg/pull/3688> (TableIdentifier/Namespace) and #3580 <https://github.com/apache/iceberg/pull/3580> (TableMetadata) but notice that both PRs still don't show the full potential of Immutables as they only convert objects to being Immutable + using the generated builders + doing some fairly easy validation checks. The real benefit gets more obvious when we can get rid of hand-written JSON serializers/deserializers. Eduard