Skip to content

Commit ef91313

Browse files
rupertwjhoeller
authored andcommitted
Use String::isEmpty instead of "".equals(arg) when arg is not null
1 parent b2b0df8 commit ef91313

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

spring-beans/src/main/java/org/springframework/beans/propertyeditors/StringTrimmerEditor.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -72,7 +72,7 @@ public void setAsText(@Nullable String text) {
7272
if (this.charsToDelete != null) {
7373
value = StringUtils.deleteAny(value, this.charsToDelete);
7474
}
75-
if (this.emptyAsNull && "".equals(value)) {
75+
if (this.emptyAsNull && value.isEmpty()) {
7676
setValue(null);
7777
}
7878
else {

spring-context/src/main/java/org/springframework/jndi/JndiTemplateEditor.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -38,7 +38,7 @@ public void setAsText(@Nullable String text) throws IllegalArgumentException {
3838
if (text == null) {
3939
throw new IllegalArgumentException("JndiTemplate cannot be created from null string");
4040
}
41-
if ("".equals(text)) {
41+
if (text.isEmpty()) {
4242
// empty environment
4343
setValue(new JndiTemplate());
4444
}

spring-orm/src/main/java/org/springframework/orm/jpa/support/PersistenceAnnotationBeanPostProcessor.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -472,7 +472,7 @@ protected EntityManagerFactory getPersistenceUnit(@Nullable String unitName) {
472472
unitNameForLookup = this.defaultPersistenceUnitName;
473473
}
474474
String jndiName = this.persistenceUnits.get(unitNameForLookup);
475-
if (jndiName == null && "".equals(unitNameForLookup) && this.persistenceUnits.size() == 1) {
475+
if (jndiName == null && unitNameForLookup.isEmpty() && this.persistenceUnits.size() == 1) {
476476
jndiName = this.persistenceUnits.values().iterator().next();
477477
}
478478
if (jndiName != null) {
@@ -505,7 +505,7 @@ protected EntityManager getPersistenceContext(@Nullable String unitName, boolean
505505
unitNameForLookup = this.defaultPersistenceUnitName;
506506
}
507507
String jndiName = contexts.get(unitNameForLookup);
508-
if (jndiName == null && "".equals(unitNameForLookup) && contexts.size() == 1) {
508+
if (jndiName == null && unitNameForLookup.isEmpty() && contexts.size() == 1) {
509509
jndiName = contexts.values().iterator().next();
510510
}
511511
if (jndiName != null) {

spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebConnection.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -110,7 +110,7 @@ public MockMvcWebConnection(MockMvc mockMvc, WebClient webClient, String context
110110
* @param contextPath the path to validate
111111
*/
112112
static void validateContextPath(@Nullable String contextPath) {
113-
if (contextPath == null || "".equals(contextPath)) {
113+
if (contextPath == null || contextPath.isEmpty()) {
114114
return;
115115
}
116116
Assert.isTrue(contextPath.startsWith("/"), () -> "contextPath '" + contextPath + "' must start with '/'.");

spring-test/src/main/java/org/springframework/test/web/servlet/setup/PatternMappingFilterProxy.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -82,7 +82,7 @@ else if (urlPattern.endsWith(PATH_MAPPING_PATTERN)) {
8282
this.exactMatches.add(urlPattern.substring(0, urlPattern.length() - 2));
8383
}
8484
else {
85-
if ("".equals(urlPattern)) {
85+
if (urlPattern.isEmpty()) {
8686
urlPattern = "/";
8787
}
8888
this.exactMatches.add(urlPattern);

spring-web/src/main/java/org/springframework/web/util/WebUtils.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -695,7 +695,7 @@ public static Map<String, Object> getParametersStartingWith(ServletRequest reque
695695
}
696696
while (paramNames != null && paramNames.hasMoreElements()) {
697697
String paramName = paramNames.nextElement();
698-
if ("".equals(prefix) || paramName.startsWith(prefix)) {
698+
if (prefix.isEmpty() || paramName.startsWith(prefix)) {
699699
String unprefixed = paramName.substring(prefix.length());
700700
String[] values = request.getParameterValues(paramName);
701701
if (values == null || values.length == 0) {

0 commit comments

Comments
 (0)