Class RecordPatternsPreviewExamples
java.lang.Object
net.jrodolfo.java_evolution.java19.RecordPatternsPreviewExamples
Demonstrates record patterns as a Java 19 preview feature.
Records made data-carrier classes concise, but extracting values still required accessor calls after checking the type. Record patterns solve that by letting code match and deconstruct a record in the same expression.
Record patterns became final later, in Java 21. The record-pattern form shown here remains syntactically and semantically faithful to the Java 19 preview while documenting that preview origin.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordSmall record used by the record pattern example. -
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
RecordPatternsPreviewExamples
public RecordPatternsPreviewExamples()
-
-
Method Details
-
describe
-