Collection.isEmpty() should be used to test for emptiness

Closes gh-1670
This commit is contained in:
igor-suhorukov
2018-02-09 00:31:43 +03:00
committed by Stephane Nicoll
parent 7da40abba5
commit e381514b07
14 changed files with 17 additions and 17 deletions

View File

@@ -40,7 +40,7 @@ class DatabasePopulatorConfigUtils {
public static void setDatabasePopulator(Element element, BeanDefinitionBuilder builder) {
List<Element> scripts = DomUtils.getChildElementsByTagName(element, "script");
if (scripts.size() > 0) {
if (!scripts.isEmpty()) {
builder.addPropertyValue("databasePopulator", createDatabasePopulator(element, scripts, "INIT"));
builder.addPropertyValue("databaseCleaner", createDatabasePopulator(element, scripts, "DESTROY"));
}

View File

@@ -293,7 +293,7 @@ public class CallMetaDataContext {
if (this.outParameterNames.size() > 1) {
logger.warn("Accessing single output value when procedure has more than one output parameter");
}
return (this.outParameterNames.size() > 0 ? this.outParameterNames.get(0) : null);
return (!this.outParameterNames.isEmpty() ? this.outParameterNames.get(0) : null);
}
}
@@ -388,7 +388,7 @@ public class CallMetaDataContext {
SqlParameter param;
if (meta.getParameterType() == DatabaseMetaData.procedureColumnReturn) {
param = declaredParams.get(getFunctionReturnName());
if (param == null && getOutParameterNames().size() > 0) {
if (param == null && !getOutParameterNames().isEmpty()) {
param = declaredParams.get(getOutParameterNames().get(0).toLowerCase());
}
if (param == null) {

View File

@@ -184,7 +184,7 @@ public class TableMetaDataContext {
if (generatedKeyNames.length > 0) {
this.generatedKeyColumnsUsed = true;
}
if (declaredColumns.size() > 0) {
if (!declaredColumns.isEmpty()) {
return new ArrayList<>(declaredColumns);
}
Set<String> keys = new LinkedHashSet<>(generatedKeyNames.length);

View File

@@ -61,7 +61,7 @@ public class GeneratedKeyHolder implements KeyHolder {
@Override
@Nullable
public Number getKey() throws InvalidDataAccessApiUsageException, DataRetrievalFailureException {
if (this.keyList.size() == 0) {
if (this.keyList.isEmpty()) {
return null;
}
if (this.keyList.size() > 1 || this.keyList.get(0).size() > 1) {
@@ -89,7 +89,7 @@ public class GeneratedKeyHolder implements KeyHolder {
@Override
@Nullable
public Map<String, Object> getKeys() throws InvalidDataAccessApiUsageException {
if (this.keyList.size() == 0) {
if (this.keyList.isEmpty()) {
return null;
}
if (this.keyList.size() > 1)