Use Collections.isEmpty() instead of .size() == 0
Ensure that Collections.isEmpty() is used to check if there are no elements in a collections. This is more explicit and can be faster than calling .size(). Closes gh-4783
This commit is contained in:
committed by
Phillip Webb
parent
6113643cbe
commit
786aacf2e9
@@ -50,7 +50,7 @@ public abstract class AnyNestedCondition extends AbstractNestedCondition {
|
||||
|
||||
@Override
|
||||
protected ConditionOutcome getFinalMatchOutcome(MemberMatchOutcomes memberOutcomes) {
|
||||
return new ConditionOutcome(memberOutcomes.getMatches().size() > 0,
|
||||
return new ConditionOutcome(!memberOutcomes.getMatches().isEmpty(),
|
||||
"nested any match resulted in " + memberOutcomes.getMatches()
|
||||
+ " matches and " + memberOutcomes.getNonMatches()
|
||||
+ " non matches");
|
||||
|
||||
@@ -47,7 +47,7 @@ class OnResourceCondition extends SpringBootCondition {
|
||||
? this.defaultResourceLoader : context.getResourceLoader();
|
||||
List<String> locations = new ArrayList<String>();
|
||||
collectValues(locations, attributes.get("resources"));
|
||||
Assert.isTrue(locations.size() > 0,
|
||||
Assert.isTrue(!locations.isEmpty(),
|
||||
"@ConditionalOnResource annotations must specify at least one resource location");
|
||||
for (String location : locations) {
|
||||
if (!loader
|
||||
|
||||
@@ -106,7 +106,7 @@ public class AutoConfigurationReportLoggingInitializer
|
||||
this.report = ConditionEvaluationReport
|
||||
.get(this.applicationContext.getBeanFactory());
|
||||
}
|
||||
if (this.report.getConditionAndOutcomesBySource().size() > 0) {
|
||||
if (!this.report.getConditionAndOutcomesBySource().isEmpty()) {
|
||||
if (isCrashReport && this.logger.isInfoEnabled()
|
||||
&& !this.logger.isDebugEnabled()) {
|
||||
this.logger.info("\n\nError starting ApplicationContext. "
|
||||
|
||||
Reference in New Issue
Block a user