Pattern Matching in Java: Better Code, Better APIs
summary
Java moves common instance-of + cast + visitor boilerplate into declarative patterns so a four-step ad hoc test becomes a three-line query using Java 24 features: record patterns for nested decomposition, switch expressions with pattern cases and exhaustiveness via sealed classes, plus underscore wildcards. Records provide transparent construction and pattern-based deconstruction; non-record classes can declare deconstructors to enable the same matching and simplify null handling and serialization (feature used by Victor Clang’s data‑oriented serialization). Primitive patterns are a 24 preview.
AI-written summary · about
chapters (12)
- 0:00Pattern matching intro
- 7:58Records and basics
- 10:30What are patterns
- 12:54Records as carriers
- 14:00Record patterns
- 16:08Switch expressions
- 20:41Sealed classes
- 23:06Unnamed variables
- 24:08Primitives matching
- 27:16Beyond deconstruction
- 33:58Data-oriented summary
- 35:44Q&A
related talks
52mPattern Matching: Small Enhancement or Major Feature?
54mPattern Matching in Java: Past, Present, Future
56mThe Art of Java Language Pattern Matching
50mPattern Matching in Java Deep Dive
39mPattern Matching: Small Enhancement or Major Feature?
29mThe Art of Java Language Pattern Matching
22mPattern Matching
01h 01mPattern Matching in Java
