Skip to content

Commit 0b1dc94

Browse files
committed
Merge pull request #4783 from kirill-vlasov
* pr/4783: Use Collections.isEmpty() instead of .size() == 0
2 parents 6113643 + 786aacf commit 0b1dc94

File tree

19 files changed

+23
-23
lines changed

19 files changed

+23
-23
lines changed

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/HealthIndicatorAutoConfigurationProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public List<String> getOrder() {
3939
}
4040

4141
public void setOrder(List<String> statusOrder) {
42-
if (statusOrder != null && statusOrder.size() > 0) {
42+
if (statusOrder != null && !statusOrder.isEmpty()) {
4343
this.order = statusOrder;
4444
}
4545
}

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/OrderedHealthAggregator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ protected Status aggregateStatus(List<Status> candidates) {
7676
}
7777
}
7878
// If no status is given return UNKNOWN
79-
if (filteredCandidates.size() == 0) {
79+
if (filteredCandidates.isEmpty()) {
8080
return Status.UNKNOWN;
8181
}
8282
// Sort given Status instances by configured order

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/AnyNestedCondition.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public AnyNestedCondition(ConfigurationPhase configurationPhase) {
5050

5151
@Override
5252
protected ConditionOutcome getFinalMatchOutcome(MemberMatchOutcomes memberOutcomes) {
53-
return new ConditionOutcome(memberOutcomes.getMatches().size() > 0,
53+
return new ConditionOutcome(!memberOutcomes.getMatches().isEmpty(),
5454
"nested any match resulted in " + memberOutcomes.getMatches()
5555
+ " matches and " + memberOutcomes.getNonMatches()
5656
+ " non matches");

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnResourceCondition.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public ConditionOutcome getMatchOutcome(ConditionContext context,
4747
? this.defaultResourceLoader : context.getResourceLoader();
4848
List<String> locations = new ArrayList<String>();
4949
collectValues(locations, attributes.get("resources"));
50-
Assert.isTrue(locations.size() > 0,
50+
Assert.isTrue(!locations.isEmpty(),
5151
"@ConditionalOnResource annotations must specify at least one resource location");
5252
for (String location : locations) {
5353
if (!loader

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/logging/AutoConfigurationReportLoggingInitializer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public void logAutoConfigurationReport(boolean isCrashReport) {
106106
this.report = ConditionEvaluationReport
107107
.get(this.applicationContext.getBeanFactory());
108108
}
109-
if (this.report.getConditionAndOutcomesBySource().size() > 0) {
109+
if (!this.report.getConditionAndOutcomesBySource().isEmpty()) {
110110
if (isCrashReport && this.logger.isInfoEnabled()
111111
&& !this.logger.isDebugEnabled()) {
112112
this.logger.info("\n\nError starting ApplicationContext. "

spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HintCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public ExitStatus run(String... args) throws Exception {
5757
if (index == 0) {
5858
showCommandHints(starting);
5959
}
60-
else if ((arguments.size() > 0) && (starting.length() > 0)) {
60+
else if (!arguments.isEmpty() && (starting.length() > 0)) {
6161
String command = arguments.remove(0);
6262
showCommandOptionHints(command, Collections.unmodifiableList(arguments),
6363
starting);

spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerationRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ else if (isDetectType()) {
385385
if (types.size() == 1) {
386386
return types.values().iterator().next();
387387
}
388-
else if (types.size() == 0) {
388+
else if (types.isEmpty()) {
389389
throw new ReportableException("No type found with build '" + this.build
390390
+ "' and format '" + this.format
391391
+ "' check the service capabilities (--list)");

spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/SourceOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ private SourceOptions(List<?> nonOptionArguments, ClassLoader classLoader) {
9696
}
9797
this.args = Collections.unmodifiableList(
9898
nonOptionArguments.subList(sourceArgCount, nonOptionArguments.size()));
99-
Assert.isTrue(sources.size() > 0, "Please specify at least one file");
99+
Assert.isTrue(!sources.isEmpty(), "Please specify at least one file");
100100
this.sources = Collections.unmodifiableList(sources);
101101
}
102102

spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ExtendedGroovyClassLoader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ private URL[] getGroovyJars(final ClassLoader parent) {
187187
if (urls.isEmpty()) {
188188
findGroovyJarsFromClassPath(parent, urls);
189189
}
190-
Assert.state(urls.size() > 0, "Unable to find groovy JAR");
190+
Assert.state(!urls.isEmpty(), "Unable to find groovy JAR");
191191
return new ArrayList<URL>(urls).toArray(new URL[urls.size()]);
192192
}
193193

spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/snake/SnakeTimer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class SnakeTimer {
4242
private static final ConcurrentHashMap<Integer, Snake> snakes = new ConcurrentHashMap<Integer, Snake>();
4343

4444
public static synchronized void addSnake(Snake snake) {
45-
if (snakes.size() == 0) {
45+
if (snakes.isEmpty()) {
4646
startTimer();
4747
}
4848
snakes.put(Integer.valueOf(snake.getId()), snake);
@@ -54,7 +54,7 @@ public static Collection<Snake> getSnakes() {
5454

5555
public static synchronized void removeSnake(Snake snake) {
5656
snakes.remove(Integer.valueOf(snake.getId()));
57-
if (snakes.size() == 0) {
57+
if (snakes.isEmpty()) {
5858
stopTimer();
5959
}
6060
}

0 commit comments

Comments
 (0)