diff --git a/news/4.34/images/ifelse-to-switch-null-21-after.png b/news/4.34/images/ifelse-to-switch-null-21-after.png new file mode 100644 index 00000000..ea635751 Binary files /dev/null and b/news/4.34/images/ifelse-to-switch-null-21-after.png differ diff --git a/news/4.34/images/ifelse-to-switch-null-after.png b/news/4.34/images/ifelse-to-switch-null-after.png new file mode 100644 index 00000000..c7c2fabf Binary files /dev/null and b/news/4.34/images/ifelse-to-switch-null-after.png differ diff --git a/news/4.34/images/ifelse-to-switch-null-before.png b/news/4.34/images/ifelse-to-switch-null-before.png new file mode 100644 index 00000000..b018343a Binary files /dev/null and b/news/4.34/images/ifelse-to-switch-null-before.png differ diff --git a/news/4.34/images/ifelseboolean-after.png b/news/4.34/images/ifelseboolean-after.png new file mode 100644 index 00000000..5e0fd8c0 Binary files /dev/null and b/news/4.34/images/ifelseboolean-after.png differ diff --git a/news/4.34/images/ifelseboolean-before.png b/news/4.34/images/ifelseboolean-before.png new file mode 100644 index 00000000..692335ec Binary files /dev/null and b/news/4.34/images/ifelseboolean-before.png differ diff --git a/news/4.34/jdt.html b/news/4.34/jdt.html index cbea8acb..70b6304c 100644 --- a/news/4.34/jdt.html +++ b/news/4.34/jdt.html @@ -65,6 +65,32 @@

JUnit

Java Editor

+ + New boolean if/else clean-up + + A new clean-up has been created to combine two opposite boolean returns controlled by an if statement into a single return where possible. +

To use the clean-up, go to the Code Style tab of the clean-up configuration dialog under Control statements and select: Simplify boolean if/else to single return if possible.

+

For example, applying the clean-up to the following code:

+

convert boolean if/else to single return before

+

results in:

+

convert boolean if/else to single return after

+ + + + Null handling for if/else to switch clean-up + + The if/else to switch clean-up has been enhanced to properly handle the case where the value can be null. In the if/else statement, this is handled intrinsically either by an else statement or falling through the if/else if, but when converting to a switch statement, either the switch must be embedded in an if statement to test for null or for Java 21 or above, a case null statement needs to be added. +

The clean-up is accessed on the Code style tab of the clean-up configuration dialog under Control statements and selecting: Convert if/else if/else chain with 3 blocks min to switch.

+

Applying the clean-up to the following code:

+

convert if/else to switch before

+

results in the following when Java version is less than 21

+

convert if/else to switch after

+

and results in the following when the Java release is set to 21 and up:

+

convert if/else to switch after for Java 21 and up

+ + + +