Pattern Matching: Small Enhancement or Major Feature?
summary
Pattern matching removes repetitive casts (JEP 305) and binds variables inline, cutting an equals implementation to a one‑liner and a switch example from ~25 lines to 11 while keeping business logic visible. Pattern matching for instanceof (Java 14 preview, finalized Java 16) and pattern matching for switch (arrived in Java 17, still evolving in Java 20 previews) work with records and sealed types; deconstruction/record patterns are in preview and enable direct field binding. Demos compile and tests run; proposed future uses include safer, readable serialization via constructor/destructor annotations.
AI-written summary · about
chapters (18)
- 0:00Introduction to pattern matching
- 1:09Java community and research
- 2:34What is pattern matching?
- 6:12Type pattern demo
- 9:26Type pattern in Java 16
- 10:09Pattern matching in switch
- 14:44Visitor pattern alternative
- 17:20Guarded patterns in switch
- 21:16Deconstruction patterns
- 23:48Deconstruction in records
- 28:38Pattern combinations
- 33:24Deconstruction pattern availability
- 34:07Sealed types and records
- 37:05Future serialization with patterns
- 42:00Unnamed patterns
- 48:32Pattern bind statements
- 49:36Future array patterns
- 50:18Conclusion: Major feature
related talks
39mPattern Matching: Small Enhancement or Major Feature?
54mPattern Matching in Java: Past, Present, Future
29mThe Art of Java Language Pattern Matching
38mPattern Matching in Java: Better Code, Better APIs
50mPattern Matching in Java Deep Dive
22mPattern Matching
56mThe Art of Java Language Pattern Matching
46mThe Art of Java Type Patterns
