Class RecordPatternsSecondPreviewExamples

java.lang.Object
net.jrodolfo.java_evolution.java20.RecordPatternsSecondPreviewExamples

public class RecordPatternsSecondPreviewExamples extends Object
Demonstrates record patterns as refined in the Java 20 second preview.

Record patterns reduce the gap between declaring transparent data with records and extracting that data later. Java 20 refined the preview, especially around nested record patterns, so code can match a structure and bind its interesting pieces in one place.

Record patterns became final in Java 21. This project compiles on JDK 25, so the example uses final syntax while documenting the Java 20 preview status.

  • Constructor Details

    • RecordPatternsSecondPreviewExamples

      public RecordPatternsSecondPreviewExamples()
  • Method Details

    • describe

      public String describe(Object value)
      Deconstructs nested records with record patterns.
      Parameters:
      value - the value to inspect
      Returns:
      a formatted address label