Fixing squid:S1155 - Collection.isEmpty() should be used to test for emptiness

This commit is contained in:
Artyom Melnikov committed 2016-06-22 13:43:15 +03:00
1 parent a64a020e36
commit 0a3b819991
66 files changed
+92 -92

No files matched your search

@@ -794,7 +794,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
}
}
if (matchSet.size() == 0) {
if (matchSet.isEmpty()) {
// this is a unidirectional relationship
// ... that is no matching property on the 'detail' bean
return false;
@@ -1141,7 +1141,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
// already assigned (So custom or UUID)
return;
}
if (desc.propertiesId().size() == 0) {
if (desc.propertiesId().isEmpty()) {
// bean doesn't have an Id property
if (desc.isBaseTableType() && desc.getBeanFinder() == null) {
// expecting an id property
@@ -283,7 +283,7 @@ public class DeployBeanDescriptor<T> {
docStoreUpdate = docStore.update();
docStoreDelete = docStore.delete();
String doc = docStore.doc();
if (doc.length() > 0) {
if (!doc.isEmpty()) {
docStorePathProperties = PathProperties.parse(doc);
}
}
@@ -388,7 +388,7 @@ public class DeployBeanDescriptor<T> {
public void setCache(Cache cache) {
String naturalKey = null;
if (cache.naturalKey().length() > 0) {
if (!cache.naturalKey().isEmpty()) {
// find the property and mark as natural key property
String propName = cache.naturalKey().trim();
DeployBeanProperty beanProperty = getBeanProperty(propName);
@@ -477,7 +477,7 @@ public class DeployBeanDescriptor<T> {
* Return the BeanPersistController (could be a chain of them, 1 or null).
*/
public BeanPersistController getPersistController() {
if (persistControllers.size() == 0) {
if (persistControllers.isEmpty()) {
return null;
} else if (persistControllers.size() == 1) {
return persistControllers.get(0);
@@ -490,7 +490,7 @@ public class DeployBeanDescriptor<T> {
* Return the BeanPersistListener (could be a chain of them, 1 or null).
*/
public BeanPersistListener getPersistListener() {
if (persistListeners.size() == 0) {
if (persistListeners.isEmpty()) {
return null;
} else if (persistListeners.size() == 1) {
return persistListeners.get(0);
@@ -500,7 +500,7 @@ public class DeployBeanDescriptor<T> {
}
public BeanQueryAdapter getQueryAdapter() {
if (queryAdapters.size() == 0) {
if (queryAdapters.isEmpty()) {
return null;
} else if (queryAdapters.size() == 1) {
return queryAdapters.get(0);
@@ -513,7 +513,7 @@ public class DeployBeanDescriptor<T> {
* Return the BeanPostLoad (could be a chain of them, 1 or null).
*/
public BeanPostLoad getPostLoad() {
if (postLoaders.size() == 0) {
if (postLoaders.isEmpty()) {
return null;
} else if (postLoaders.size() == 1) {
return postLoaders.get(0);
@@ -835,7 +835,7 @@ public class DeployBeanDescriptor<T> {
return null;
}
String selectClause = sb.toString();
if (selectClause.length() == 0) {
if (selectClause.isEmpty()) {
throw new IllegalStateException("Bean " + getFullName() + " has no properties?");
}
return selectClause.substring(0, selectClause.length() - 1);
@@ -386,7 +386,7 @@ public class DeployBeanProperty {
* Set a specific DB column definition.
*/
public void setDbColumnDefn(String dbColumnDefn) {
if (dbColumnDefn == null || dbColumnDefn.trim().length() == 0) {
if (dbColumnDefn == null || dbColumnDefn.trim().isEmpty()) {
this.dbColumnDefn = null;
} else {
this.dbColumnDefn = InternString.intern(dbColumnDefn);
@@ -178,7 +178,7 @@ public class DeployBeanPropertyAssocMany<T> extends DeployBeanPropertyAssoc<T> {
* Set the default mapKey to use when returning a Map.
*/
public void setMapKey(String mapKey) {
if (mapKey != null && mapKey.length() > 0) {
if (mapKey != null && !mapKey.isEmpty()) {
this.mapKey = mapKey;
}
}
@@ -188,7 +188,7 @@ public class DeployBeanPropertyAssocMany<T> extends DeployBeanPropertyAssoc<T> {
* list, set or map.
*/
public void setFetchOrderBy(String orderBy) {
if (orderBy != null && orderBy.length() > 0) {
if (orderBy != null && !orderBy.isEmpty()) {
fetchOrderBy = orderBy;
}
}
@@ -46,7 +46,7 @@ public class DeployTableJoin {
* Return true if the JoinOnPair have been set.
*/
public boolean hasJoinColumns() {
return columns.size() > 0;
return !columns.isEmpty();
}
/**
@@ -32,7 +32,7 @@ public abstract class AnnotationBase {
* Checks string is null or empty .
*/
protected boolean isEmpty(String s) {
return s == null || s.trim().length() == 0;
return s == null || s.trim().isEmpty();
}
@@ -188,7 +188,7 @@ public class DeployInheritInfo {
public void setDiscriminatorValue(String value) {
if (value != null) {
value = value.trim();
if (value.length() != 0) {
if (!value.isEmpty()) {
discriminatorStringValue = value;
// convert the value if desired
if (discriminatorType == Types.INTEGER) {
@@ -70,7 +70,7 @@ public class SqlReservedWords {
public static synchronized void addKeyword(String keyword){
if (keyword != null){
keyword = keyword.trim().toUpperCase();
if (keyword.length() > 0){
if (!keyword.isEmpty()){
keywords.add(keyword);
}
}