Use String::isEmpty instead of "".equals(arg) when arg is not null
This commit is contained in:
parent
4883b8aa03
commit
7dba79c7c1
|
@ -194,7 +194,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
|
|||
this.wrappedObject = ObjectUtils.unwrapOptional(object);
|
||||
Assert.notNull(this.wrappedObject, "Target object must not be null");
|
||||
this.nestedPath = (nestedPath != null ? nestedPath : "");
|
||||
this.rootObject = (!"".equals(this.nestedPath) ? rootObject : this.wrappedObject);
|
||||
this.rootObject = (!this.nestedPath.isEmpty() ? rootObject : this.wrappedObject);
|
||||
this.nestedPropertyAccessors = null;
|
||||
this.typeConverterDelegate = new TypeConverterDelegate(this, this.wrappedObject);
|
||||
}
|
||||
|
|
|
@ -247,7 +247,7 @@ class TypeConverterDelegate {
|
|||
}
|
||||
}
|
||||
String trimmedValue = ((String) convertedValue).trim();
|
||||
if (requiredType.isEnum() && "".equals(trimmedValue)) {
|
||||
if (requiredType.isEnum() && trimmedValue.isEmpty()) {
|
||||
// It's an empty enum identifier: reset the enum value to null.
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -162,7 +162,7 @@ public class SpringValidatorAdapter implements SmartValidator, javax.validation.
|
|||
// as necessary for Hibernate Validator compatibility (non-indexed set path in field)
|
||||
BindingResult bindingResult = (BindingResult) errors;
|
||||
String nestedField = bindingResult.getNestedPath() + field;
|
||||
if ("".equals(nestedField)) {
|
||||
if (nestedField.isEmpty()) {
|
||||
String[] errorCodes = bindingResult.resolveMessageCodes(errorCode);
|
||||
ObjectError error = new ObjectError(
|
||||
errors.getObjectName(), errorCodes, errorArgs, violation.getMessage());
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -468,7 +468,7 @@ public class PersistenceAnnotationBeanPostProcessor
|
|||
protected EntityManagerFactory getPersistenceUnit(@Nullable String unitName) {
|
||||
if (this.persistenceUnits != null) {
|
||||
String unitNameForLookup = (unitName != null ? unitName : "");
|
||||
if ("".equals(unitNameForLookup)) {
|
||||
if (unitNameForLookup.isEmpty()) {
|
||||
unitNameForLookup = this.defaultPersistenceUnitName;
|
||||
}
|
||||
String jndiName = this.persistenceUnits.get(unitNameForLookup);
|
||||
|
@ -501,7 +501,7 @@ public class PersistenceAnnotationBeanPostProcessor
|
|||
Map<String, String> contexts = (extended ? this.extendedPersistenceContexts : this.persistenceContexts);
|
||||
if (contexts != null) {
|
||||
String unitNameForLookup = (unitName != null ? unitName : "");
|
||||
if ("".equals(unitNameForLookup)) {
|
||||
if (unitNameForLookup.isEmpty()) {
|
||||
unitNameForLookup = this.defaultPersistenceUnitName;
|
||||
}
|
||||
String jndiName = contexts.get(unitNameForLookup);
|
||||
|
@ -533,10 +533,10 @@ public class PersistenceAnnotationBeanPostProcessor
|
|||
throws NoSuchBeanDefinitionException {
|
||||
|
||||
String unitNameForLookup = (unitName != null ? unitName : "");
|
||||
if ("".equals(unitNameForLookup)) {
|
||||
if (unitNameForLookup.isEmpty()) {
|
||||
unitNameForLookup = this.defaultPersistenceUnitName;
|
||||
}
|
||||
if (!"".equals(unitNameForLookup)) {
|
||||
if (!unitNameForLookup.isEmpty()) {
|
||||
return findNamedEntityManagerFactory(unitNameForLookup, requestingBeanName);
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Reference in New Issue