Records and Sealed Hierarchies
Records are concise data carriers. Sealed types restrict extension to a known set.
sealed interface Shape permits Circle, Rectangle {}
record Circle(double radius) implements Shape {}
record Rectangle(double width, double height) implements Shape {}
Together, these features help model closed domains where the variants are intentionally known.
Key Takeaways
Records reduce boilerplate for data carriers.
Sealed types explicitly close an inheritance hierarchy.
The combination is useful for finite domain variants.