Use .isEmpty() instead of .length() == 0 (#3314)

Minor nit - since String is a CharSequence it's advisable to use the
corresponding method for checking the condition rather than writing
it by hand.
This commit is contained in:
Hubert Plociniczak 2022-03-04 16:41:48 +01:00 committed by GitHub
parent 8bdca89917
commit ac5c02ed8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -170,8 +170,8 @@ public class Text_Utils {
public static boolean contains(String string, String substring) {
// {@code StringSearch} does not handle empty strings as we would want, so we need these special
// cases.
if (substring.length() == 0) return true;
if (string.length() == 0) return false;
if (substring.isEmpty()) return true;
if (string.isEmpty()) return false;
StringSearch searcher = new StringSearch(substring, string);
return searcher.first() != StringSearch.DONE;
}

View File

@ -93,7 +93,7 @@ public class Parser {
}
private String handleNa(String raw) {
if (raw == null || raw.length() == 0) {
if (raw == null || raw.isEmpty()) {
return null;
}
return raw;