Pattern Matching: Small Enhancement or Major Feature?
summary
Shows that pattern matching for instanceof (JEP 305, landed in Java 14 and finalized in Java 16) compresses type test + cast + bind into one expression, and that pattern matching for switch (preview in Java 17/18) replaces long else-if chains with typed cases, guarded patterns and null labels. Demonstrates deconstruction patterns, pattern definitions, var/any/array patterns, and how records + sealed types make switches exhaustive. Proposes using pattern definitions to drive safer, readable serialization and links demo code on GitHub.
AI-written summary · about
chapters (9)
- 0:00Introduction
- 5:16Practicalities
- 8:34Effects
- 16:45Guarded Patterns
- 18:23Deconstruction Patterns
- 26:35Seal Types
- 30:42Better Serialization
- 35:33More Ideas
- 37:53Conclusion
related talks
52mPattern Matching: Small Enhancement or Major Feature?
54mPattern Matching in Java: Past, Present, Future
29mThe Art of Java Language Pattern Matching
46mThe Art of Java Type Patterns
50mPattern Matching in Java Deep Dive
46mThe Art of Java Type Patterns
56mThe Art of Java Language Pattern Matching
22mPattern Matching
