Reports classes that can be converted to record classes.

Record classes focus on modeling immutable data rather than extensible behavior. Automatic implicit implementation of data-driven methods, such as equals() and accessors, helps to reduce boilerplate code.

Note that not every class can be a record class. Here are some restrictions:

For a full description of record classes, refer to the Java Language Specification.

Example:


  class Point {
    private final double x;
    private final double y;

    Point(double x, double y) {
      this.x = x;
      this.y = y;
    }

    double getX() {
      return x;
    }

    double getY() {
      return y;
    }
  }

After the quick-fix is applied:


  record Point(int x, int y) {
  }

Enable the Suggest renaming accessor methods option to rename getX()/isX() accessors to x() automatically.

Use the Disable highlighting if members become more accessible option to exclude classes whose members' accessibility would be weakened by conversion. Quick-fix will stay available as an intention, and triggering it will show the affected members and ask for confirmation. In batch mode conversion will not be suggested.

Use the Suppress conversion if the class is annotated by list to exclude classes from conversion when annotated by annotations matching the specified patterns.

New in 2020.3