mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-07 22:09:38 +07:00
29 lines
629 B
HTML
29 lines
629 B
HTML
<html>
|
|
<body>
|
|
Reports patterns that can be replaced with record patterns.
|
|
<p>Example:</p>
|
|
<pre><code>
|
|
record Point(int x, int y) {
|
|
static void printSum(Object obj) {
|
|
if (obj instanceof Point p) {
|
|
int x = p.x();
|
|
int y = p.y();
|
|
System.out.println(x + y);
|
|
}
|
|
}
|
|
}
|
|
</code></pre>
|
|
<p>After the quick-fix is applied:</p>
|
|
<pre><code>
|
|
record Point(int x, int y) {
|
|
static void printSum(Object obj) {
|
|
if (obj instanceof Point(int x, int y)) {
|
|
System.out.println(x + y);
|
|
}
|
|
}
|
|
}
|
|
</code></pre>
|
|
<!-- tooltip end -->
|
|
<p><small>New in 2023.1</small></p>
|
|
</body>
|
|
</html> |