mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
38 lines
1.3 KiB
HTML
38 lines
1.3 KiB
HTML
<html>
|
|
<body>
|
|
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.
|
|
<p><b>Example:</b></p>
|
|
<pre><code>
|
|
record Record(Integer x, String y) {
|
|
}
|
|
|
|
public static void test(List<Record> records) {
|
|
for (Record record : records) {
|
|
System.out.println(record.y());
|
|
Integer x = record.x;
|
|
System.out.println(x);
|
|
}
|
|
}
|
|
</code></pre>
|
|
<p>Can be replaced with:</p>
|
|
<pre><code>
|
|
record Record(Integer x, String y) {
|
|
}
|
|
|
|
public static void test(List<Record> records) {
|
|
for (Record(Integer x, String y) : records) {
|
|
System.out.println(y);
|
|
System.out.println(x);
|
|
}
|
|
}
|
|
</code></pre>
|
|
<!-- tooltip end -->
|
|
<ul>
|
|
<li>Use the <b>Nesting depth limit</b> option to specify the maximum number of nested deconstruction patterns to report</li>
|
|
<li>Use the <b>Maximum number of record components to deconstruct</b> option to specify the maximum number of components, which a record can contain to be used in deconstruction patterns</li>
|
|
<li>Use the <b>Maximum number of not-used record components</b> option to specify the maximum number of components, which are not used in <code>for</code> statement</li>
|
|
</ul>
|
|
|
|
<p><small>New in 2023.1</small></p>
|
|
</body>
|
|
</html> |