Skip to content

Commit 451f90c

Browse files
committed
use isEmpty check
Signed-off-by: Deepak <sdeepaksharma15@gmail.com>
1 parent ed2cad3 commit 451f90c

File tree

26 files changed

+36
-36
lines changed

26 files changed

+36
-36
lines changed

integration-tests/src/test/java/org/springframework/beans/factory/xml/ComponentFactoryBean.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void setChildren(List<Component> children) {
3535

3636
@Override
3737
public Component getObject() {
38-
if (this.children != null && this.children.size() > 0) {
38+
if (this.children != null && !this.children.isEmpty()) {
3939
for (Component child : children) {
4040
this.parent.addComponent(child);
4141
}

spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,18 +379,18 @@ protected List<String> calculateFilenamesForLocale(String basename, Locale local
379379
StringBuilder temp = new StringBuilder(basename);
380380

381381
temp.append('_');
382-
if (language.length() > 0) {
382+
if (!language.isEmpty()) {
383383
temp.append(language);
384384
result.add(0, temp.toString());
385385
}
386386

387387
temp.append('_');
388-
if (country.length() > 0) {
388+
if (!country.isEmpty()) {
389389
temp.append(country);
390390
result.add(0, temp.toString());
391391
}
392392

393-
if (variant.length() > 0 && (language.length() > 0 || country.length() > 0)) {
393+
if (!variant.isEmpty() && (!language.isEmpty() || !country.isEmpty())) {
394394
temp.append('_').append(variant);
395395
result.add(0, temp.toString());
396396
}

spring-context/src/testFixtures/java/org/springframework/context/testfixture/jndi/SimpleNamingContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ private AbstractNamingEnumeration(SimpleNamingContext context, String proot) thr
326326
}
327327
}
328328
}
329-
if (contents.size() == 0) {
329+
if (contents.isEmpty()) {
330330
throw new NamingException("Invalid root: [" + context.root + proot + "]");
331331
}
332332
this.iterator = contents.values().iterator();

spring-core/src/main/java/org/springframework/asm/TypePath.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public int getStepArgument(final int index) {
117117
* @return the corresponding TypePath object, or {@literal null} if the path is empty.
118118
*/
119119
public static TypePath fromString(final String typePath) {
120-
if (typePath == null || typePath.length() == 0) {
120+
if (typePath == null || typePath.isEmpty()) {
121121
return null;
122122
}
123123
int typePathLength = typePath.length();

spring-core/src/main/java/org/springframework/cglib/proxy/CallbackHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public CallbackHelper(Class superclass, Class[] interfaces) {
6363
abstract protected Object getCallback(Method method);
6464

6565
public Callback[] getCallbacks() {
66-
if (callbacks.size() == 0) {
66+
if (callbacks.isEmpty()) {
6767
return new Callback[0];
6868
}
6969
if (callbacks.get(0) instanceof Callback) {
@@ -75,7 +75,7 @@ public Callback[] getCallbacks() {
7575
}
7676

7777
public Class[] getCallbackTypes() {
78-
if (callbacks.size() == 0) {
78+
if (callbacks.isEmpty()) {
7979
return new Class[0];
8080
}
8181
if (callbacks.get(0) instanceof Callback) {

spring-core/src/main/java/org/springframework/cglib/proxy/Enhancer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ public void generateClass(ClassVisitor v) throws Exception {
755755
*/
756756
protected void filterConstructors(Class sc, List constructors) {
757757
CollectionUtils.filter(constructors, new VisibilityPredicate(sc, true));
758-
if (constructors.size() == 0) {
758+
if (constructors.isEmpty()) {
759759
throw new IllegalArgumentException("No visible constructors in " + sc);
760760
}
761761
}

spring-core/src/main/java/org/springframework/core/io/support/LocalizedResourceHelper.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,20 +100,20 @@ public Resource findLocalizedResource(String name, String extension, @Nullable L
100100
String variant = locale.getVariant();
101101

102102
// Check for file with language, country and variant localization.
103-
if (variant.length() > 0) {
103+
if (!variant.isEmpty()) {
104104
String location =
105105
name + this.separator + lang + this.separator + country + this.separator + variant + extension;
106106
resource = this.resourceLoader.getResource(location);
107107
}
108108

109109
// Check for file with language and country localization.
110-
if ((resource == null || !resource.exists()) && country.length() > 0) {
110+
if ((resource == null || !resource.exists()) && !country.isEmpty()) {
111111
String location = name + this.separator + lang + this.separator + country + extension;
112112
resource = this.resourceLoader.getResource(location);
113113
}
114114

115115
// Check for document with language localization.
116-
if ((resource == null || !resource.exists()) && lang.length() > 0) {
116+
if ((resource == null || !resource.exists()) && !lang.isEmpty()) {
117117
String location = name + this.separator + lang + extension;
118118
resource = this.resourceLoader.getResource(location);
119119
}

spring-core/src/main/java/org/springframework/core/io/support/PropertySourceProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public void processPropertySource(PropertySourceDescriptor descriptor) throws IO
8080
String name = descriptor.name();
8181
String encoding = descriptor.encoding();
8282
List<String> locations = descriptor.locations();
83-
Assert.isTrue(locations.size() > 0, "At least one @PropertySource(value) location is required");
83+
Assert.isTrue(!locations.isEmpty(), "At least one @PropertySource(value) location is required");
8484
boolean ignoreResourceNotFound = descriptor.ignoreResourceNotFound();
8585
PropertySourceFactory factory = (descriptor.propertySourceFactory() != null ?
8686
instantiateClass(descriptor.propertySourceFactory()) : defaultPropertySourceFactory);

spring-core/src/main/java/org/springframework/util/AntPathMatcher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ private boolean isPotentialMatch(String path, String[] pattDirs) {
348348
pos += skipped;
349349
skipped = skipSegment(path, pos, pattDir);
350350
if (skipped < pattDir.length()) {
351-
return (skipped > 0 || (pattDir.length() > 0 && isWildcardChar(pattDir.charAt(0))));
351+
return (skipped > 0 || (!pattDir.isEmpty() && isWildcardChar(pattDir.charAt(0))));
352352
}
353353
pos += skipped;
354354
}

spring-core/src/main/java/org/springframework/util/CommonsLogWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public CommonsLogWriter(Log logger) {
4444

4545

4646
public void write(char ch) {
47-
if (ch == '\n' && this.buffer.length() > 0) {
47+
if (ch == '\n' && !this.buffer.isEmpty()) {
4848
logger.debug(this.buffer.toString());
4949
this.buffer.setLength(0);
5050
}

0 commit comments

Comments
 (0)