mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-27 04:22:42 +07:00
GitOrigin-RevId: 8b2b63fc6db476ca0c2cfe5cadd84db6c4236d0f
44 lines
1.2 KiB
HTML
44 lines
1.2 KiB
HTML
<html>
|
|
<body>
|
|
Reports <code>switch</code> statements that can be automatically replaced with enhanced <code>switch</code> statements or expressions.
|
|
<p><b>Example:</b></p>
|
|
<pre><code>
|
|
double getPrice(String fruit) {
|
|
// Switch statement can be replaced with enhanced 'switch'
|
|
switch (fruit) {
|
|
case "Apple":
|
|
return 1.0;
|
|
case "Orange":
|
|
return 1.5;
|
|
case "Mango":
|
|
return 2.0;
|
|
default:
|
|
throw new IllegalArgumentException();
|
|
}
|
|
}
|
|
</code></pre>
|
|
<p>After the quick-fix is applied:</p>
|
|
<pre><code>
|
|
double getPrice(String fruit) {
|
|
return switch (fruit) {
|
|
case "Apple" -> 1.0;
|
|
case "Orange" -> 1.5;
|
|
case "Mango" -> 2.0;
|
|
default -> throw new IllegalArgumentException();
|
|
};
|
|
}
|
|
</code></pre>
|
|
<!-- tooltip end -->
|
|
<p>
|
|
<ul>
|
|
<li>
|
|
Use the <b>Show warning only if conversion to expression is possible</b> option not to warn about conversion to <code>switch</code> statement.
|
|
</li>
|
|
<li>
|
|
Use the <b>Maximum number of statements in one branch to convert to switch expression</b> option warn about conversion to expression only
|
|
if each branch has less than the given number of statements.
|
|
</li>
|
|
</ul>
|
|
<p><small>New in 2019.1</small></p>
|
|
</body>
|
|
</html> |