Bug 573289 - [cleanup] String.strip().isEmpty() => String.isBlank()

String.isBlank() rather than String.strip().isEmpty()

String.isBlank() is shorter than checking the stripped string or
checking the length of the stripped string and it avoids the creation of
an intermediate trimmed string.

To apply the cleanup also to String.trim().isEmpty() (which is probably
more common than String.strip().isEmpty(), since strip() exists only
since Java 11), trim() must first be replaced by strip() which may
change the runtime behavior.

Given:
if (input.strip().isEmpty()) {
    System.err.println("Input must not be blank");
}
boolean hasComment = comment.strip().length() > 0;

When:
Clean up the code enabling "String.isBlank() rather than
String.strip().isEmpty()" and using Java 11 or higher

Then:
if (input.isBlank()) {
    System.err.println("Input must not be blank");
}
boolean hasComment = !comment.isBlank();

Also use Java 12 Runtime jar for the Java 11 tests instead of Java 10
Runtime jar

Change-Id: I6db90845ea19ade65dfaeff43330adf77d72813f
Signed-off-by: Holger Voormann <eclipse@voormann.de>
Reviewed-on: https://git.eclipse.org/r/c/jdt/eclipse.jdt.ui/+/180067
Tested-by: JDT Bot <jdt-bot@eclipse.org>
Reviewed-by: Fabrice Tiercelin <fabrice.tiercelin@yahoo.fr>
Depends-On: I072b6e18fa951ab9901e3363b55be2c18654888f
diff --git a/4.20/images/isblank-after.png b/4.20/images/isblank-after.png
new file mode 100644
index 0000000..0b66e30
--- /dev/null
+++ b/4.20/images/isblank-after.png
Binary files differ
diff --git a/4.20/images/isblank-before.png b/4.20/images/isblank-before.png
new file mode 100644
index 0000000..0d05580
--- /dev/null
+++ b/4.20/images/isblank-before.png
Binary files differ
diff --git a/4.20/images/isblank-preferences.png b/4.20/images/isblank-preferences.png
new file mode 100644
index 0000000..e2d801b
--- /dev/null
+++ b/4.20/images/isblank-preferences.png
Binary files differ
diff --git a/4.20/jdt.html b/4.20/jdt.html
index e82aaa7..0fff925 100644
--- a/4.20/jdt.html
+++ b/4.20/jdt.html
@@ -194,6 +194,44 @@
     </td>
   </tr>
   
+  <tr id="isblank"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=573289 -->
+    <td class="title"><a href="#isblank">Uses String.isBlank() clean up</a></td>
+    <td class="content">
+      A new clean up has been added that replaces the check of the emptiness of <code>String.strip()</code> by the use of <code>String.isBlank()</code>.
+      <p>
+        It avoids the cost of the creation of a stripped string.
+      </p>
+      <p>
+        You may use Java 11 or higher to use it.
+      </p>
+      <p>
+         In order to apply this cleanup also to <code>trim().isEmpty()</code>,
+         you might consider to replace
+         <code>trim()</code>, which exists since the beginning of Java, with
+         <code>strip()</code> that has been introduced in Java 11 together with <code>isBlank()</code>,
+      </p>
+      <p>
+         But watch out, <code>trim()</code> and <code>strip()</code> differ:
+         <code>trim()</code> removes leading and trailing characters with an ASCII code up to 32,
+         including some non white space ASCII control characters and
+         missing some Unicode white space characters,
+         whereas <code>strip()</code> removes all and only leading and trailing white space.
+      </p>
+      <p>
+        To apply the clean up, select <b>String.isBlank() rather than String.strip().isEmpty()</b> check box on the <b>Optimization</b> tab in your clean up profile.
+      </p>
+      <p><img src="images/isblank-preferences.png" alt="Preferences" width="800"/></p>
+      <p>
+        For the given code:
+      </p>
+      <p><img src="images/isblank-before.png" alt="Before"/></p>
+      <p>
+        One gets:
+      </p>
+      <p><img src="images/isblank-after.png" alt="After"/></p>
+    </td>
+  </tr>
+  
   <tr id="valueof-rather-than-instantiation"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=572234 -->
     <td class="title"><a href="#valueof-rather-than-instantiation">valueOf() rather than instantiation clean up</a></td>
     <td class="content">