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) { public static boolean contains(String string, String substring) {
// {@code StringSearch} does not handle empty strings as we would want, so we need these special // {@code StringSearch} does not handle empty strings as we would want, so we need these special
// cases. // cases.
if (substring.length() == 0) return true; if (substring.isEmpty()) return true;
if (string.length() == 0) return false; if (string.isEmpty()) return false;
StringSearch searcher = new StringSearch(substring, string); StringSearch searcher = new StringSearch(substring, string);
return searcher.first() != StringSearch.DONE; return searcher.first() != StringSearch.DONE;
} }

View File

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