image credit: Freepik

JEP 405: Record Classes to Extend Pattern Matching in Java

May 26, 2022

Via: InfoQ

JEP 405, Record Patterns (Preview), has been promoted from Proposed to Target to Targeted for JDK 19. Under the umbrella of Project Amber, this JEP proposes to enhance the language with record patterns to deconstruct record values. Record patterns may be used in conjunction with type patterns to “enable a robust, declarative, and composable form of data navigation and processing. This is still a preview feature.

JEP 394, Pattern Matching for instanceof, delivered in JDK 16, extended the instanceof operator to take a type pattern and perform pattern matching. Consider the following example:

Read More on InfoQ