Statement can be replaced with enhanced 'switch'
Reports switch
statements that can be automatically replaced with enhanced switch
statements or expressions.
Example:
After the quick-fix is applied:
Use the Show warning only if conversion to expression is possible option not to warn about conversion to
switch
statement.Use the Maximum number of statements in one branch to convert to switch expression option warn about conversion to expression only if each branch has less than the given number of statements.
This inspection only reports if the language level of the project or module is 14 or higher
New in 2019.1
Inspection options
Option | Type | Default |
---|---|---|
Show warning only if conversion to expression is possible | Checkbox | true |
Maximum number of statements in one branch to convert to switch expression | Number | 2 |
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |