Enhanced 'for' with a record pattern can be used
Reports local variable declarations and accessors to record components that can be replaced with pattern variables in enhanced `for` statements, which are usually more compact.
Example:
Can be replaced with:
This inspection only reports if the language level of the project or module is 20 or higher
Use the Nesting depth limit option to specify the maximum number of nested deconstruction patterns to report
Use the Maximum number of record components to deconstruct option to specify the maximum number of components, which a record can contain to be used in deconstruction patterns
Use the Maximum number of not-used record components option to specify the maximum number of components, which are not used in
for
statement
New in 2023.1
Inspection options
Option | Type | Default |
---|---|---|
Nesting depth limit | Number | 2 |
Maximum number of record components to deconstruct | Number | 5 |
Maximum number of not-used record components | Number | 0 |
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |