Algebraic Data Types
summary
Code and examples on GitHub demonstrate Java's algebraic data types: enums, Optionals, generics-based tuples, preview records (Java 14/15) and sealed types (Java 15), plus pattern matching via instanceof and Class.isAssignableFrom. Compact record constructors validate and throw NullPointerException or custom exceptions; local records show scoped declarations; sealed classes use permits to block an octagon example and allow only declared subclasses; tuples implemented as Pair/Twin work with generics; all examples compile and run, printing the expected outputs.
AI-written summary · about
chapters (8)
- 0:00Introduction to ADTs
- 2:28Java enums explained
- 8:05Optional types in Java
- 13:39Sealed classes overview
- 19:17Product types in Java
- 23:31Java records deep dive
- 29:46Pattern matching recap
- 30:07Summary and closing
related talks
31mAlgebraic Data Type in Java 17
31mData Oriented Programming and Matching in Java
36mJava Language Futures - Mid 2020 Edition
49mData-oriented Programming in Java
56mThe Art of Java Language Pattern Matching
54mData Oriented Programming with the JDK 19
54mData Focused programming with Pattern Matching in Java
01h 10mBack to Basics: Algebraic Data Types
