Use String::isEmpty instead of "".equals(arg) when arg is not null

This commit is contained in:
stsypanov
2018-08-26 22:43:50 +03:00
committed by Juergen Hoeller
parent 4883b8aa03
commit 7dba79c7c1
8 changed files with 13 additions and 13 deletions

View File

@@ -49,7 +49,7 @@ final class StringToBooleanConverter implements Converter<String, Boolean> {
@Override
public Boolean convert(String source) {
String value = source.trim();
if ("".equals(value)) {
if (value.isEmpty()) {
return null;
}
value = value.toLowerCase();

View File

@@ -571,8 +571,8 @@ public class AntPathMatcher implements PathMatcher {
int dotPos2 = pattern2.indexOf('.');
String file2 = (dotPos2 == -1 ? pattern2 : pattern2.substring(0, dotPos2));
String ext2 = (dotPos2 == -1 ? "" : pattern2.substring(dotPos2));
boolean ext1All = (ext1.equals(".*") || ext1.equals(""));
boolean ext2All = (ext2.equals(".*") || ext2.equals(""));
boolean ext1All = (ext1.equals(".*") || ext1.isEmpty());
boolean ext2All = (ext2.equals(".*") || ext2.isEmpty());
if (!ext1All && !ext2All) {
throw new IllegalArgumentException("Cannot combine patterns: " + pattern1 + " vs " + pattern2);
}

View File

@@ -52,7 +52,7 @@ public abstract class PatternMatchUtils {
return str.endsWith(pattern.substring(1));
}
String part = pattern.substring(1, nextIndex);
if ("".equals(part)) {
if (part.isEmpty()) {
return simpleMatch(pattern.substring(nextIndex), str);
}
int partIndex = str.indexOf(part);

View File

@@ -821,7 +821,7 @@ public abstract class StringUtils {
}
}
if ("".equals(variant) && country.startsWith("#")) {
if (variant.isEmpty() && country.startsWith("#")) {
variant = country;
country = "";
}
@@ -1192,7 +1192,7 @@ public abstract class StringUtils {
}
List<String> result = new ArrayList<>();
if ("".equals(delimiter)) {
if (delimiter.isEmpty()) {
for (int i = 0; i < str.length(); i++) {
result.add(deleteAny(str.substring(i, i + 1), charsToDelete));
}