This is an automated email from the ASF dual-hosted git repository.
pawan pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git The following commit(s) were added to refs/heads/trunk by this push: new 6cb67c1 Improved: Replace .size() == 0 with isEmpty() in Java files(OFBIZ-11944) 6cb67c1 is described below commit 6cb67c1a404957c26c964c0f6e6579360abaf4d9 Author: Pawan Verma <[hidden email]> AuthorDate: Sat Aug 22 19:17:10 2020 +0530 Improved: Replace .size() == 0 with isEmpty() in Java files(OFBIZ-11944) Thanks, priya for the report and patch and jacques for the review. --- .../accounting/agreement/AgreementServices.java | 4 +- .../ofbiz/accounting/invoice/InvoiceServices.java | 26 ++++----- .../accounting/payment/BillingAccountWorker.java | 2 +- .../accounting/payment/PaymentGatewayServices.java | 2 +- .../accounting/payment/PaymentMethodServices.java | 20 +++---- .../ofbiz/accounting/tax/TaxAuthorityServices.java | 8 +-- .../accounting/thirdparty/paypal/PayPalEvents.java | 2 +- .../thirdparty/valuelink/ValueLinkApi.java | 2 +- .../accounting/thirdparty/verisign/PayflowPro.java | 4 +- .../thirdparty/worldpay/WorldPayEvents.java | 2 +- .../ofbiz/content/ContentManagementServices.java | 6 +- .../ofbiz/content/ContentManagementWorker.java | 6 +- .../java/org/apache/ofbiz/content/ConvertTree.java | 4 +- .../ofbiz/content/content/ContentKeywordIndex.java | 2 +- .../ofbiz/content/content/ContentSearch.java | 12 ++-- .../ofbiz/content/content/ContentWorker.java | 6 +- .../content/content/UploadContentAndImage.java | 4 +- .../ofbiz/content/data/DataResourceWorker.java | 2 +- .../apache/ofbiz/content/layout/LayoutWorker.java | 4 +- .../webapp/ftl/CheckPermissionTransform.java | 2 +- .../ftl/LimitedSubContentCacheTransform.java | 2 +- .../webapp/ftl/RenderSubContentCacheTransform.java | 2 +- .../ftl/TraverseSubContentCacheTransform.java | 2 +- .../apache/ofbiz/manufacturing/bom/BOMNode.java | 4 +- .../ofbiz/manufacturing/bom/BOMServices.java | 4 +- .../apache/ofbiz/manufacturing/bom/BOMTree.java | 2 +- .../ofbiz/manufacturing/mrp/ProposedOrder.java | 2 +- .../manufacturing/techdata/TechDataServices.java | 2 +- .../ofbiz/marketing/report/ReportHelper.java | 2 +- .../marketing/tracking/TrackingCodeEvents.java | 8 +-- .../apache/ofbiz/order/order/OrderListState.java | 4 +- .../ofbiz/order/order/OrderLookupServices.java | 6 +- .../apache/ofbiz/order/order/OrderReadHelper.java | 4 +- .../ofbiz/order/order/OrderReturnServices.java | 10 ++-- .../apache/ofbiz/order/order/OrderServices.java | 26 ++++----- .../ofbiz/order/shoppingcart/CheckOutEvents.java | 10 ++-- .../ofbiz/order/shoppingcart/CheckOutHelper.java | 24 ++++---- .../ofbiz/order/shoppingcart/ShoppingCart.java | 6 +- .../order/shoppingcart/ShoppingCartEvents.java | 10 ++-- .../order/shoppingcart/ShoppingCartHelper.java | 14 ++--- .../order/shoppingcart/ShoppingCartServices.java | 2 +- .../shoppingcart/product/ProductDisplayWorker.java | 2 +- .../shoppingcart/product/ProductPromoWorker.java | 8 +-- .../apache/ofbiz/order/test/OrderTestServices.java | 2 +- .../ofbiz/order/thirdparty/taxware/TaxwareUTL.java | 4 +- .../communication/CommunicationEventServices.java | 12 ++-- .../ofbiz/party/contact/ContactMechServices.java | 16 +++--- .../ofbiz/party/contact/ContactMechWorker.java | 4 +- .../apache/ofbiz/party/party/PartyServices.java | 36 ++++++------ .../ofbiz/product/catalog/CatalogWorker.java | 2 +- .../ofbiz/product/category/CatalogUrlFilter.java | 2 +- .../ofbiz/product/category/CategoryServices.java | 2 +- .../product/category/SeoContentUrlFilter.java | 4 +- .../category/ftl/CatalogUrlSeoTransform.java | 2 +- .../ofbiz/product/config/ProductConfigWorker.java | 4 +- .../ofbiz/product/config/ProductConfigWrapper.java | 2 +- .../product/feature/ProductFeatureServices.java | 10 ++-- .../imagemanagement/ImageManagementServices.java | 2 +- .../product/imagemanagement/ReplaceImage.java | 2 +- .../ofbiz/product/inventory/InventoryServices.java | 2 +- .../ofbiz/product/inventory/InventoryWorker.java | 2 +- .../apache/ofbiz/product/price/PriceServices.java | 2 +- .../apache/ofbiz/product/product/KeywordIndex.java | 2 +- .../ofbiz/product/product/ProductEvents.java | 22 ++++---- .../ofbiz/product/product/ProductSearch.java | 64 +++++++++++----------- .../product/product/ProductSearchSession.java | 4 +- .../ofbiz/product/product/ProductServices.java | 12 ++-- .../ofbiz/product/product/ProductUtilServices.java | 14 ++--- .../apache/ofbiz/product/promo/PromoServices.java | 8 +-- .../spreadsheetimport/ImportProductServices.java | 2 +- .../product/subscription/SubscriptionServices.java | 8 +-- .../product/supplier/SupplierProductServices.java | 4 +- .../ofbiz/shipment/packing/PackingSession.java | 6 +- .../ofbiz/shipment/shipment/ShipmentServices.java | 4 +- .../ofbiz/shipment/shipment/ShipmentWorker.java | 2 +- .../ofbiz/shipment/thirdparty/dhl/DhlServices.java | 8 +-- .../ofbiz/shipment/thirdparty/ups/UpsServices.java | 14 ++--- .../shipment/thirdparty/usps/UspsServices.java | 2 +- .../ofbiz/shipment/verify/VerifyPickSession.java | 2 +- .../ofbiz/workeffort/workeffort/ICalConverter.java | 4 +- .../workeffort/workeffort/ICalRecurConverter.java | 14 ++--- .../ofbiz/workeffort/workeffort/ICalWorker.java | 4 +- .../workeffort/WorkEffortKeywordIndex.java | 2 +- .../workeffort/workeffort/WorkEffortSearch.java | 12 ++-- .../workeffort/workeffort/WorkEffortServices.java | 2 +- .../ofbiz/base/conversion/DateTimeConverters.java | 14 ++--- .../ofbiz/base/conversion/NumberConverters.java | 2 +- .../ofbiz/base/test/GenericTestCaseBase.java | 4 +- .../java/org/apache/ofbiz/base/util/Assert.java | 6 +- .../java/org/apache/ofbiz/base/util/FileUtil.java | 2 +- .../org/apache/ofbiz/base/util/ObjectType.java | 26 ++++----- .../org/apache/ofbiz/base/util/ScriptUtil.java | 4 +- .../org/apache/ofbiz/base/util/StringUtil.java | 2 +- .../org/apache/ofbiz/base/util/UtilProperties.java | 2 +- .../util/collections/FlexibleServletAccessor.java | 2 +- .../util/collections/ResourceBundleMapWrapper.java | 2 +- .../org/apache/ofbiz/common/CommonServices.java | 2 +- .../java/org/apache/ofbiz/common/FindServices.java | 6 +- .../java/org/apache/ofbiz/common/FtpServices.java | 4 +- .../org/apache/ofbiz/common/KeywordSearchUtil.java | 4 +- .../apache/ofbiz/common/image/ImageTransform.java | 2 +- .../apache/ofbiz/common/login/LoginServices.java | 8 +-- .../apache/ofbiz/common/status/StatusWorker.java | 2 +- .../apache/ofbiz/datafile/DataFile2EntityXml.java | 2 +- .../apache/ofbiz/datafile/ModelDataFileReader.java | 2 +- .../org/apache/ofbiz/datafile/RecordIterator.java | 2 +- .../org/apache/ofbiz/entity/GenericDelegator.java | 10 ++-- .../org/apache/ofbiz/entity/GenericEntity.java | 6 +- .../entity/condition/EntityConditionSubSelect.java | 4 +- .../apache/ofbiz/entity/condition/EntityExpr.java | 2 +- .../apache/ofbiz/entity/datasource/GenericDAO.java | 18 +++--- .../ofbiz/entity/finder/EntityFinderUtil.java | 4 +- .../org/apache/ofbiz/entity/finder/ListFinder.java | 2 +- .../org/apache/ofbiz/entity/jdbc/DatabaseUtil.java | 2 +- .../org/apache/ofbiz/entity/jdbc/SqlJdbcUtil.java | 2 +- .../ofbiz/entity/model/DynamicViewEntity.java | 2 +- .../org/apache/ofbiz/entity/model/ModelEntity.java | 2 +- .../org/apache/ofbiz/entity/model/ModelReader.java | 6 +- .../apache/ofbiz/entity/model/ModelViewEntity.java | 6 +- .../ofbiz/entity/transaction/TransactionUtil.java | 2 +- .../apache/ofbiz/entityext/EntityGroupUtil.java | 2 +- .../ofbiz/entityext/data/EntityDataServices.java | 4 +- .../ofbiz/entityext/eca/EntityEcaCondition.java | 2 +- .../permission/EntityPermissionChecker.java | 6 +- .../synchronization/EntitySyncContext.java | 14 ++--- .../org/apache/ofbiz/minilang/MiniLangUtil.java | 6 +- .../apache/ofbiz/minilang/MiniLangValidate.java | 10 ++-- .../org/apache/ofbiz/minilang/SimpleMethod.java | 4 +- .../minilang/method/callops/CallClassMethod.java | 2 +- .../minilang/method/callops/CallObjectMethod.java | 2 +- .../ofbiz/minilang/method/callops/CallScript.java | 2 +- .../minilang/method/callops/CallSimpleMethod.java | 8 +-- .../minilang/method/callops/SetServiceFields.java | 2 +- .../method/conditional/CombinedCondition.java | 10 ++-- .../ofbiz/minilang/method/envops/CheckErrors.java | 2 +- .../ofbiz/minilang/method/envops/CreateObject.java | 2 +- .../ofbiz/minilang/method/envops/Iterate.java | 2 +- .../ofbiz/minilang/method/envops/IterateMap.java | 2 +- .../ofbiz/minilang/method/envops/OrderMapList.java | 2 +- .../ofbiz/minilang/method/envops/SetCalendar.java | 4 +- .../ofbiz/minilang/method/envops/SetOperation.java | 8 +-- .../method/eventops/RequestParametersToList.java | 2 +- .../apache/ofbiz/minilang/method/otherops/Log.java | 2 +- .../minilang/method/otherops/PropertyToField.java | 2 +- .../minilang/method/serviceops/FieldToResult.java | 2 +- .../apache/ofbiz/minilang/operation/Convert.java | 2 +- .../org/apache/ofbiz/minilang/operation/Copy.java | 2 +- .../org/apache/ofbiz/service/ModelService.java | 14 ++--- .../apache/ofbiz/service/ModelServiceReader.java | 2 +- .../apache/ofbiz/service/ServiceDispatcher.java | 2 +- .../java/org/apache/ofbiz/service/ServiceUtil.java | 4 +- .../ofbiz/service/calendar/RecurrenceRule.java | 2 +- .../service/calendar/TemporalExpressions.java | 4 +- .../ofbiz/service/eca/ServiceEcaCondition.java | 2 +- .../org/apache/ofbiz/service/group/GroupModel.java | 2 +- .../ofbiz/service/group/GroupServiceModel.java | 2 +- .../ofbiz/service/group/ServiceGroupReader.java | 2 +- .../apache/ofbiz/service/mail/ServiceMcaUtil.java | 2 +- .../service/test/ServiceEngineTestServices.java | 4 +- .../ofbiz/webapp/control/RequestHandler.java | 4 +- .../control/WebAppServletContextListener.java | 2 +- .../org/apache/ofbiz/webapp/event/CoreEvents.java | 2 +- .../ofbiz/webapp/event/ServiceEventHandler.java | 4 +- .../webapp/event/ServiceMultiEventHandler.java | 6 +- .../ofbiz/webapp/ftl/OfbizContentTransform.java | 2 +- .../org/apache/ofbiz/webtools/GenericWebEvent.java | 6 +- .../apache/ofbiz/webtools/WebToolsServices.java | 6 +- .../webtools/artifactinfo/ServiceArtifactInfo.java | 2 +- .../artifactinfo/ServiceEcaArtifactInfo.java | 2 +- .../webtools/labelmanager/LabelReferences.java | 2 +- .../webtools/template/entity/ModelInduceFromDb.jsp | 2 +- .../webtools/template/entity/xmldsrawdump.jsp | 2 +- .../ofbiz/widget/model/AbstractModelAction.java | 2 +- .../ofbiz/widget/model/AbstractModelCondition.java | 4 +- .../org/apache/ofbiz/widget/model/ModelForm.java | 2 +- .../apache/ofbiz/widget/model/ModelFormField.java | 4 +- .../org/apache/ofbiz/widget/model/ModelTree.java | 2 +- .../ofbiz/widget/model/ModelWidgetCondition.java | 4 +- .../apache/ofbiz/widget/model/ThemeFactory.java | 4 +- .../apache/ofbiz/widget/renderer/FormRenderer.java | 14 ++--- .../ofbiz/widget/renderer/ScreenRenderer.java | 2 +- 181 files changed, 501 insertions(+), 501 deletions(-) diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/agreement/AgreementServices.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/agreement/AgreementServices.java index 2faec01..f356845 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/agreement/AgreementServices.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/agreement/AgreementServices.java @@ -92,7 +92,7 @@ public class AgreementServices { .where("productId", productId, "agreementItemTypeId", "AGREEMENT_COMMISSION") .cache().filterByDate().queryList(); // Try the first available virtual product if this is a variant product - if (agreementItems.size() == 0) { + if (agreementItems.isEmpty()) { GenericValue productAssoc = EntityQuery.use(delegator).from("ProductAssoc") .where("productIdTo", productId, "productAssocTypeId", "PRODUCT_VARIANT") .cache().filterByDate().queryFirst(); @@ -109,7 +109,7 @@ public class AgreementServices { "agreementItemSeqId", agreementItem.getString("agreementItemSeqId"), "invoiceItemTypeId", invoiceItemTypeId) .cache().queryList(); - if (terms.size() > 0) { + if (!terms.isEmpty()) { BigDecimal commission = ZERO; BigDecimal min = new BigDecimal("-1e12"); // Limit to 1 trillion commission BigDecimal max = new BigDecimal("1e12"); diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java index 719c9a9..dcd7d42 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java @@ -124,7 +124,7 @@ public class InvoiceServices { try { List<GenericValue> orderItems = EntityQuery.use(delegator).from("OrderItem") .where("orderId", context.get("orderId")).orderBy("orderItemSeqId").queryList(); - if (orderItems.size() > 0) { + if (!orderItems.isEmpty()) { context.put("billItems", orderItems); } // get the system userid and store in context otherwise the invoice add service does not work @@ -1297,7 +1297,7 @@ public class InvoiceServices { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "AccountingProblemGettingItemsFromShipments", locale)); } - if (itemIssuances.size() == 0) { + if (itemIssuances.isEmpty()) { Debug.logInfo("No items issued for shipments", MODULE); return ServiceUtil.returnSuccess(); } @@ -1476,7 +1476,7 @@ public class InvoiceServices { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "AccountingProblemGettingItemsFromShipments", locale)); } - if (items.size() == 0) { + if (items.isEmpty()) { Debug.logInfo("No items issued for shipments", MODULE); return ServiceUtil.returnSuccess(); } @@ -1519,7 +1519,7 @@ public class InvoiceServices { } // if none found, then okay to bill - if (itemBillings.size() == 0) { + if (itemBillings.isEmpty()) { itemsByOrder.add(item); } @@ -1583,7 +1583,7 @@ public class InvoiceServices { // add up the already billed total - if (billed.size() > 0) { + if (!billed.isEmpty()) { BigDecimal billedQuantity = BigDecimal.ZERO; for (GenericValue oib : billed) { BigDecimal qty = oib.getBigDecimal("quantity"); @@ -3254,7 +3254,7 @@ public class InvoiceServices { toMessage = UtilProperties.getMessage(RESOURCE, "AccountingApplicationToInvoice", UtilMisc.toMap("invoiceId", invoiceId), locale); - if (extra.length() > 0) { + if (!extra.isEmpty()) { toMessage = UtilProperties.getMessage(RESOURCE, "AccountingApplicationToInvoiceItem", UtilMisc.toMap("invoiceId", invoiceId, "invoiceItemSeqId", invoiceItemSeqId), locale); @@ -3303,7 +3303,7 @@ public class InvoiceServices { "toMessage", toMessage), locale); } // report error messages if any - if (errorMessageList.size() > 0) { + if (!errorMessageList.isEmpty()) { return ServiceUtil.returnError(errorMessageList); } @@ -3357,7 +3357,7 @@ public class InvoiceServices { } catch (GenericEntityException e) { return ServiceUtil.returnError(e.getMessage()); } - if (invoiceItems.size() == 0) { + if (invoiceItems.isEmpty()) { errorMessageList.add(UtilProperties.getMessage(RESOURCE, "AccountingNoInvoiceItemsFoundForInvoice", UtilMisc.toMap("invoiceId", invoiceId), locale)); return ServiceUtil.returnError(errorMessageList); @@ -3440,7 +3440,7 @@ public class InvoiceServices { } - if (errorMessageList.size() > 0) { + if (!errorMessageList.isEmpty()) { return ServiceUtil.returnError(errorMessageList); } if (successMessage != null) { @@ -3520,7 +3520,7 @@ public class InvoiceServices { } catch (GenericEntityException e) { return ServiceUtil.returnError(e.getMessage()); } - if (checkAppls.size() > 0) { + if (!checkAppls.isEmpty()) { if (debug) { Debug.logInfo(checkAppls.size() + " records already exist", MODULE); } @@ -3729,7 +3729,7 @@ public class InvoiceServices { Debug.logError("Valication checking problem against database. due to " + e.getMessage(), MODULE); } - if (newErrMsgs.size() > 0) { + if (!newErrMsgs.isEmpty()) { errMsgs.addAll(newErrMsgs); } else { Map<String, Object> invoiceResult = null; @@ -3794,7 +3794,7 @@ public class InvoiceServices { Debug.logError("Validation checking problem against database. due to " + e.getMessage(), MODULE); } - if (newErrMsgs.size() > 0) { + if (!newErrMsgs.isEmpty()) { errMsgs.addAll(newErrMsgs); } else { try { @@ -3816,7 +3816,7 @@ public class InvoiceServices { return ServiceUtil.returnError(e.getMessage()); } - if (errMsgs.size() > 0) { + if (!errMsgs.isEmpty()) { return ServiceUtil.returnError(errMsgs); } diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/BillingAccountWorker.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/BillingAccountWorker.java index 1dd5d61..6286ae8 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/BillingAccountWorker.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/BillingAccountWorker.java @@ -73,7 +73,7 @@ public final class BillingAccountWorker { .where(EntityCondition.makeCondition("partyId", EntityOperator.IN, relatedPartyIdList), EntityCondition.makeCondition("roleTypeId", EntityOperator.EQUALS, "BILL_TO_CUSTOMER")).filterByDate().queryList(); - if (billingAccountRoleList.size() > 0) { + if (!billingAccountRoleList.isEmpty()) { BigDecimal totalAvailable = BigDecimal.ZERO; for (GenericValue billingAccountRole : billingAccountRoleList) { GenericValue billingAccountVO = billingAccountRole.getRelatedOne("BillingAccount", false); diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentGatewayServices.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentGatewayServices.java index 6c8fcc7..088992e 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentGatewayServices.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentGatewayServices.java @@ -758,7 +758,7 @@ public class PaymentGatewayServices { } // return complete if no payment prefs were found - if (paymentPrefs.size() == 0) { + if (paymentPrefs.isEmpty()) { Debug.logWarning("No OrderPaymentPreference records available for release", MODULE); result.put("processResult", "COMPLETE"); result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS); diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentMethodServices.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentMethodServices.java index 881c2c5..33fe65a 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentMethodServices.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentMethodServices.java @@ -141,7 +141,7 @@ public class PaymentMethodServices { String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PAY_INFO", "_CREATE", "ACCOUNTING", "_CREATE"); - if (result.size() > 0) { + if (!result.isEmpty()) { return result; } @@ -163,7 +163,7 @@ public class PaymentMethodServices { UtilMisc.toMap("expireDate", (String) context.get("expireDate")), locale)); } - if (messages.size() > 0) { + if (!messages.isEmpty()) { return ServiceUtil.returnError(messages); } @@ -266,7 +266,7 @@ public class PaymentMethodServices { String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PAY_INFO", "_UPDATE", "ACCOUNTING", "_UPDATE"); - if (result.size() > 0) { + if (!result.isEmpty()) { return result; } @@ -334,7 +334,7 @@ public class PaymentMethodServices { UtilMisc.toMap("expireDate", (String) context.get("expireDate")), locale)); } - if (messages.size() > 0) { + if (!messages.isEmpty()) { return ServiceUtil.returnError(messages); } @@ -499,7 +499,7 @@ public class PaymentMethodServices { String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PAY_INFO", "_CREATE", "ACCOUNTING", "_CREATE"); - if (result.size() > 0) { + if (!result.isEmpty()) { return result; } @@ -557,7 +557,7 @@ public class PaymentMethodServices { String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PAY_INFO", "_UPDATE", "ACCOUNTING", "_UPDATE"); - if (result.size() > 0) { + if (!result.isEmpty()) { return result; } @@ -692,7 +692,7 @@ public class PaymentMethodServices { String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PAY_INFO", "_CREATE", "ACCOUNTING", "_CREATE"); - if (result.size() > 0) { + if (!result.isEmpty()) { return result; } @@ -794,7 +794,7 @@ public class PaymentMethodServices { String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PAY_INFO", "_UPDATE", "ACCOUNTING", "_UPDATE"); - if (result.size() > 0) { + if (!result.isEmpty()) { return result; } @@ -931,7 +931,7 @@ public class PaymentMethodServices { Timestamp now = UtilDateTime.nowTimestamp(); String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PAY_INFO", "_CREATE", "ACCOUNTING", "_CREATE"); - if (result.size() > 0) { + if (!result.isEmpty()) { return result; } @@ -1021,7 +1021,7 @@ public class PaymentMethodServices { String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PAY_INFO", "_UPDATE", "ACCOUNTING", "_UPDATE"); - if (result.size() > 0) { + if (!result.isEmpty()) { return result; } diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/tax/TaxAuthorityServices.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/tax/TaxAuthorityServices.java index 2cdf18d..cc92b6d 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/tax/TaxAuthorityServices.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/tax/TaxAuthorityServices.java @@ -117,14 +117,14 @@ public class TaxAuthorityServices { taxAuthoritySet.add(taxAuthority); } - if (taxAuthoritySet.size() == 0) { + if (taxAuthoritySet.isEmpty()) { throw new IllegalArgumentException("Could not find any Tax Authories for store with ID [" + productStoreId + "] for tax calculation; the store settings may need to be corrected."); } List<GenericValue> taxAdustmentList = getTaxAdjustments(delegator, product, productStore, null, billToPartyId, taxAuthoritySet, basePrice, quantity, amount, shippingPrice, ZERO_BASE); - if (taxAdustmentList.size() == 0) { + if (taxAdustmentList.isEmpty()) { // this is something that happens every so often for different products and // such, so don't blow up on it... Debug.logWarning("Could not find any Tax Authories Rate Rules for store with ID [" + productStoreId @@ -427,7 +427,7 @@ public class TaxAuthorityServices { List<GenericValue> lookupList = EntityQuery.use(delegator).from("TaxAuthorityRateProduct") .where(mainCondition).orderBy("minItemPrice", "minPurchase", "fromDate").filterByDate().queryList(); - if (lookupList.size() == 0) { + if (lookupList.isEmpty()) { Debug.logWarning("In TaxAuthority Product Rate no records were found for condition:" + mainCondition .toString(), MODULE); return adjustments; @@ -702,7 +702,7 @@ public class TaxAuthorityServices { productCategoryIdSet.add(pcm.getString("productCategoryId")); } - if (productCategoryIdSet.size() == 0) { + if (productCategoryIdSet.isEmpty()) { return EntityCondition.makeCondition("productCategoryId", EntityOperator.EQUALS, null); } return EntityCondition.makeCondition( diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/paypal/PayPalEvents.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/paypal/PayPalEvents.java index 9db40b7..f0df0dc 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/paypal/PayPalEvents.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/paypal/PayPalEvents.java @@ -397,7 +397,7 @@ public class PayPalEvents { Debug.logError(e, "Cannot get payment preferences for order #" + orderId, MODULE); return false; } - if (paymentPrefs.size() > 0) { + if (!paymentPrefs.isEmpty()) { for (GenericValue pref : paymentPrefs) { boolean okay = setPaymentPreference(dispatcher, userLogin, pref, request); if (!okay) diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/valuelink/ValueLinkApi.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/valuelink/ValueLinkApi.java index 4ceb665..18fdff7 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/valuelink/ValueLinkApi.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/valuelink/ValueLinkApi.java @@ -1000,7 +1000,7 @@ public class ValueLinkApi { testResponse = StringUtil.replaceString(testResponse, "</tr>", ""); testResponse = StringUtil.replaceString(testResponse, "|", ""); testResponse = testResponse.trim(); - if (testResponse.length() == 0) { + if (testResponse.isEmpty()) { if (debug) { Debug.logInfo("History did not contain any fields, returning null", MODULE); } diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/verisign/PayflowPro.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/verisign/PayflowPro.java index 1c3023b..01dbfe2 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/verisign/PayflowPro.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/verisign/PayflowPro.java @@ -695,7 +695,7 @@ public class PayflowPro { Map<String, String> parameters = new HashMap<>(); List<String> params = StringUtil.split(resp, "&"); for (String str : params) { - if (str.length() > 0) { + if (!str.isEmpty()) { List<String> kv = StringUtil.split(str, "="); String k = kv.get(0); String v = kv.get(1); @@ -880,7 +880,7 @@ public class PayflowPro { String name = (String) i.next(); Object valueObj = context.get(name); - if (valueObj == null || (valueObj instanceof String) && ((String) valueObj).length() == 0) { + if (valueObj == null || (valueObj instanceof String) && ((String) valueObj).isEmpty()) { // not valid; do nothing } else { String value = valueObj.toString(); diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.java index 7ace333..a9c0cf7 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.java @@ -412,7 +412,7 @@ public class WorldPayEvents { Debug.logError(e, "Cannot get payment preferences for order #" + orderId, MODULE); return false; } - if (paymentPrefs.size() > 0) { + if (!paymentPrefs.isEmpty()) { for (GenericValue pref : paymentPrefs) { boolean okay = setPaymentPreference(dispatcher, userLogin, pref, request); if (!okay) { diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementServices.java b/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementServices.java index 13a9cf4..92c469b 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementServices.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementServices.java @@ -1395,9 +1395,9 @@ public class ContentManagementServices { .cache().queryList(); List<GenericValue> listThrusOnly = EntityUtil.filterOutByCondition(lst, EntityCondition.makeCondition("purchaseThruDate", EntityOperator.EQUALS, null)); - if (listThrusOnly.size() > 0) { + if (!listThrusOnly.isEmpty()) { productContent = listThrusOnly.get(0); - } else if (lst.size() > 0) { + } else if (!lst.isEmpty()) { productContent = lst.get(0); } } catch (GenericEntityException e) { @@ -1499,7 +1499,7 @@ public class ContentManagementServices { if (UtilValidate.isNotEmpty(contentAssocTypeId)) { contentAssocTypeIdList = StringUtil.split(contentAssocTypeId, "|"); } - if (contentAssocTypeIdList.size() == 0) { + if (contentAssocTypeIdList.isEmpty()) { contentAssocTypeIdList.add("SUB_CONTENT"); } Map<String, Object> ctx = new HashMap<>(); diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementWorker.java b/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementWorker.java index f4f918d..fe012d5 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementWorker.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementWorker.java @@ -386,7 +386,7 @@ public final class ContentManagementWorker { String publishPointId = publishPointArray[0]; List<GenericValue> contentAssocList = content.getRelated("ToContentAssoc", UtilMisc.toMap("contentId", publishPointId), null, false); List<GenericValue> filteredList = EntityUtil.filterByDate(contentAssocList); - if (filteredList.size() > 0) { + if (!filteredList.isEmpty()) { map.put(publishPointId, "Y"); GenericValue assoc = filteredList.get(0); Timestamp fromDate = (Timestamp) assoc.get("fromDate"); @@ -543,7 +543,7 @@ public final class ContentManagementWorker { Map<String, Object> results = ContentServicesComplex.getAssocAndContentAndDataResourceCacheMethod(delegator, contentId, null, "To", null, null, assocTypes, contentTypes, Boolean.TRUE, null, null); List<GenericValue> valueList = UtilGenerics.cast(results.get("entityList")); - if (valueList.size() > 0) { + if (!valueList.isEmpty()) { GenericValue value = valueList.get(0); authorContent = delegator.makeValue("Content"); authorContent.setPKFields(value); @@ -632,7 +632,7 @@ public final class ContentManagementWorker { List<EntityCondition> conditionMain = new ArrayList<>(); conditionMain.add(EntityCondition.makeCondition("contentIdTo", contentId)); - if (typeList.size() > 0) { + if (!typeList.isEmpty()) { conditionMain.add(EntityCondition.makeCondition("contentAssocTypeId", EntityOperator.IN, typeList)); } List<GenericValue> contentAssocs = EntityQuery.use(delegator).from("ContentAssoc").where(conditionMain) diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/ConvertTree.java b/applications/content/src/main/java/org/apache/ofbiz/content/ConvertTree.java index 44a5a16..9e3a98f 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/ConvertTree.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/ConvertTree.java @@ -186,7 +186,7 @@ In order to make this service active add the following to the service definition "contentAssocTypeId", "TREE_CHILD") .queryList(); - if (contentAssocs.size() == 0) { + if (contentAssocs.isEmpty()) { contentAssoc = new HashMap<>(); contentAssoc.put("contentId", contentId); contentAssoc.put("contentAssocTypeId", "TREE_CHILD"); @@ -257,7 +257,7 @@ In order to make this service active add the following to the service definition List<GenericValue> contentAssocsChecks = EntityQuery.use(delegator).from("ContentAssoc") .where("contentId", contentch.get("contentId"), "contentIdTo", rootContent) .queryList(); - if (contentAssocsChecks.size() > 0) { + if (!contentAssocsChecks.isEmpty()) { contentNameMatch = true; } } diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentKeywordIndex.java b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentKeywordIndex.java index 2b76946..750e379 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentKeywordIndex.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentKeywordIndex.java @@ -194,7 +194,7 @@ public class ContentKeywordIndex { toBeStored.add(contentKeyword); } } - if (toBeStored.size() > 0) { + if (!toBeStored.isEmpty()) { if (Debug.verboseOn()) { Debug.logVerbose("[ContentKeywordIndex.indexKeywords] Storing " + toBeStored.size() + " keywords for contentId " + content.getString("contentId"), MODULE); } diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentSearch.java b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentSearch.java index 0fc9da1..13e28df 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentSearch.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentSearch.java @@ -216,7 +216,7 @@ public class ContentSearch { } public void finishKeywordConstraints() { - if (orKeywordFixedSet.size() == 0 && andKeywordFixedSet.size() == 0 && keywordFixedOrSetAndList.size() == 0) { + if (orKeywordFixedSet.isEmpty() && andKeywordFixedSet.isEmpty() && keywordFixedOrSetAndList.isEmpty()) { return; } @@ -224,7 +224,7 @@ public class ContentSearch { this.includedKeywordSearch = true; // if there is anything in the orKeywordFixedSet add it to the keywordFixedOrSetAndList - if (orKeywordFixedSet.size() > 0) { + if (!orKeywordFixedSet.isEmpty()) { // put in keywordFixedOrSetAndList to process with other or lists where at least one is required keywordFixedOrSetAndList.add(orKeywordFixedSet); } @@ -233,7 +233,7 @@ public class ContentSearch { Iterator<Set<String>> keywordFixedOrSetAndTestIter = keywordFixedOrSetAndList.iterator(); while (keywordFixedOrSetAndTestIter.hasNext()) { Set<String> keywordFixedOrSet = keywordFixedOrSetAndTestIter.next(); - if (keywordFixedOrSet.size() == 0) { + if (keywordFixedOrSet.isEmpty()) { keywordFixedOrSetAndTestIter.remove(); } else if (keywordFixedOrSet.size() == 1) { // treat it as just another and @@ -242,12 +242,12 @@ public class ContentSearch { } } - boolean doingBothAndOr = (keywordFixedOrSetAndList.size() > 1) || (keywordFixedOrSetAndList.size() > 0 && andKeywordFixedSet.size() > 0); + boolean doingBothAndOr = (keywordFixedOrSetAndList.size() > 1) || (!keywordFixedOrSetAndList.isEmpty() && !andKeywordFixedSet.isEmpty()); Debug.logInfo("Finished initial setup of keywords, doingBothAndOr=" + doingBothAndOr + ", andKeywordFixedSet=" + andKeywordFixedSet + "\n keywordFixedOrSetAndList=" + keywordFixedOrSetAndList, MODULE); ComplexAlias relevancyComplexAlias = new ComplexAlias("+"); - if (andKeywordFixedSet.size() > 0) { + if (!andKeywordFixedSet.isEmpty()) { // add up the relevancyWeight fields from all keyword member entities for a total to sort by for (String keyword: andKeywordFixedSet) { @@ -271,7 +271,7 @@ public class ContentSearch { dynamicViewEntity.addAlias(null, "totalRelevancy", null, null, null, null, null, relevancyComplexAlias); } } - if (keywordFixedOrSetAndList.size() > 0) { + if (!keywordFixedOrSetAndList.isEmpty()) { for (Set<String> keywordFixedOrSet: keywordFixedOrSetAndList) { // make index based values and increment String entityAlias = "PK" + index; diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java index b66e1f4..53b0e88 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java @@ -831,10 +831,10 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor EntityExpr expr = EntityCondition.makeCondition(contentIdName, EntityOperator.EQUALS, origContentId); exprListAnd.add(expr); - if (contentTypes.size() > 0) { + if (!contentTypes.isEmpty()) { exprListAnd.add(EntityCondition.makeCondition("contentTypeId", EntityOperator.IN, contentTypes)); } - if (assocTypes.size() > 0) { + if (!assocTypes.isEmpty()) { exprListAnd.add(EntityCondition.makeCondition("contentAssocTypeId", EntityOperator.IN, assocTypes)); } @@ -1436,7 +1436,7 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor List<GenericValue> filteredList = getContentAssocViewList(delegator, contentIdTo, contentId, contentAssocTypeId, statusId, privilegeEnumId); GenericValue val = null; - if (filteredList.size() > 0) { + if (!filteredList.isEmpty()) { val = filteredList.get(0); } return val; diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/content/UploadContentAndImage.java b/applications/content/src/main/java/org/apache/ofbiz/content/content/UploadContentAndImage.java index 0645b95..bff098d 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/content/UploadContentAndImage.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/content/UploadContentAndImage.java @@ -91,7 +91,7 @@ public class UploadContentAndImage { return "error"; } - if (lst.size() == 0) { + if (lst.isEmpty()) { String errMsg = UtilProperties.getMessage(ERR_RESOURCE, "uploadContentAndImage.no_files_uploaded", locale); request.setAttribute("_ERROR_MESSAGE_", errMsg); Debug.logWarning("[DataEvents.uploadImage] No files uploaded", MODULE); @@ -361,7 +361,7 @@ public class UploadContentAndImage { return "error"; } - if (lst.size() == 0) { + if (lst.isEmpty()) { request.setAttribute("_ERROR_MESSAGE_", "No files uploaded"); Debug.logWarning("[DataEvents.uploadImage] No files uploaded", MODULE); return "error"; diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java b/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java index aa1661b..d74c1d8 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java @@ -216,7 +216,7 @@ public class DataResourceWorker implements org.apache.ofbiz.widget.content.Data return "error"; } - if (lst.size() == 0) { + if (lst.isEmpty()) { String errMsg = UtilProperties.getMessage(ERR_RESOURCE, "dataResourceWorker.no_files_uploaded", locale); request.setAttribute("_ERROR_MESSAGE_", errMsg); Debug.logWarning("[DataEvents.uploadImage] No files uploaded", MODULE); diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/layout/LayoutWorker.java b/applications/content/src/main/java/org/apache/ofbiz/content/layout/LayoutWorker.java index 739a2ec..8140565 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/layout/LayoutWorker.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/layout/LayoutWorker.java @@ -77,10 +77,10 @@ public final class LayoutWorker { return ServiceUtil.returnError(e4.getMessage()); } - if (lst.size() == 0 && UtilValidate.isNotEmpty(request.getAttribute("fileItems"))) { + if (lst.isEmpty() && UtilValidate.isNotEmpty(request.getAttribute("fileItems"))) { lst = UtilGenerics.cast(request.getAttribute("fileItems")); } - if (lst.size() == 0) { + if (lst.isEmpty()) { String errMsg = UtilProperties.getMessage(ERR_RESOURCE, "layoutEvents.no_files_uploaded", locale); request.setAttribute("_ERROR_MESSAGE_", errMsg); diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/CheckPermissionTransform.java b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/CheckPermissionTransform.java index 0e95355..8c9562b 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/CheckPermissionTransform.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/CheckPermissionTransform.java @@ -152,7 +152,7 @@ public class CheckPermissionTransform implements TemplateTransformModel { } } List<String> targetOperationList = StringUtil.split(targetOperation, "|"); - if (targetOperationList.size() == 0) { + if (targetOperationList.isEmpty()) { throw new IOException("targetOperationList has zero size."); } List<String> roleList = new LinkedList<>(); diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/LimitedSubContentCacheTransform.java b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/LimitedSubContentCacheTransform.java index 412f399..e335d73 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/LimitedSubContentCacheTransform.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/LimitedSubContentCacheTransform.java @@ -262,7 +262,7 @@ public class LimitedSubContentCacheTransform implements TemplateTransformModel { Debug.logVerbose("in limited, lst:" + lst, ""); } - while (pickEntity == null && lst.size() > 0) { + while (pickEntity == null && !lst.isEmpty()) { double randomValue = Math.random(); int idx = (int) (lst.size() * randomValue); pickEntity = lst.get(idx); diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderSubContentCacheTransform.java b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderSubContentCacheTransform.java index c368947..555cdaa 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderSubContentCacheTransform.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderSubContentCacheTransform.java @@ -139,7 +139,7 @@ public class RenderSubContentCacheTransform implements TemplateTransformModel { GenericValue thisView = null; if (view != null) { thisView = view; - } else if (passedGlobalNodeTrail.size() > 0) { + } else if (!passedGlobalNodeTrail.isEmpty()) { Map<String, ? extends Object> map = UtilGenerics.cast(passedGlobalNodeTrail.get(passedGlobalNodeTrail.size() - 1)); if (Debug.infoOn()) { Debug.logInfo("in Render(3), map ." + map, MODULE); diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/TraverseSubContentCacheTransform.java b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/TraverseSubContentCacheTransform.java index 47b8524..dd58e09 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/TraverseSubContentCacheTransform.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/TraverseSubContentCacheTransform.java @@ -150,7 +150,7 @@ public class TraverseSubContentCacheTransform implements TemplateTransformModel List<Map<String, ? extends Object>> nodeTrail = null; Map<String, Object> node = null; List<Map<String, ? extends Object>> globalNodeTrail = UtilGenerics.cast(templateRoot.get("globalNodeTrail")); - if (globalNodeTrail.size() > 0) { + if (!globalNodeTrail.isEmpty()) { int sz = globalNodeTrail.size(); nodeTrail = new LinkedList<>(); node = UtilGenerics.cast(globalNodeTrail.get(sz - 1)); diff --git a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMNode.java b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMNode.java index 79f8122..e4800e9 100644 --- a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMNode.java +++ b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMNode.java @@ -289,7 +289,7 @@ public class BOMNode { } } - if (selectedFeatures.size() > 0) { + if (!selectedFeatures.isEmpty()) { Map<String, Object> context = new HashMap<>(); context.put("productId", node.get("productIdTo")); context.put("selectedFeatures", selectedFeatures); @@ -702,7 +702,7 @@ public class BOMNode { Debug.logError("Problem in BOMNode.isManufactured()", MODULE); } supplierProducts = EntityUtil.filterByDate(supplierProducts, UtilDateTime.nowTimestamp(), "availableFromDate", "availableThruDate", true); - return childrenNodes.size() > 0 && (ignoreSupplierProducts || UtilValidate.isEmpty(supplierProducts)); + return !childrenNodes.isEmpty() && (ignoreSupplierProducts || UtilValidate.isEmpty(supplierProducts)); } /** diff --git a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMServices.java b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMServices.java index e33d02d..595034d 100644 --- a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMServices.java +++ b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMServices.java @@ -383,7 +383,7 @@ public class BOMServices { tree.setRootQuantity(quantity); tree.setRootAmount(amount); tree.print(components, excludeWIPs); - if (components.size() > 0) components.remove(0); + if (!components.isEmpty()) components.remove(0); } catch (GenericEntityException gee) { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingBomErrorCreatingBillOfMaterialsTree", UtilMisc.toMap("errorString", gee.getMessage()), locale)); } @@ -566,7 +566,7 @@ public class BOMServices { productsInPackages = null; } } - if (productsInPackages != null && productsInPackages.size() == 0) { + if (productsInPackages != null && productsInPackages.isEmpty()) { productsInPackages = null; } if (UtilValidate.isNotEmpty(productsInPackages)) { diff --git a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMTree.java b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMTree.java index fbd752d..033ec13 100644 --- a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMTree.java +++ b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMTree.java @@ -179,7 +179,7 @@ public class BOMTree { public boolean isConfigured() { List<BOMNode> notConfiguredParts = new LinkedList<>(); root.isConfigured(notConfiguredParts); - return (notConfiguredParts.size() == 0); + return (notConfiguredParts.isEmpty()); } /** Getter for property rootQuantity. diff --git a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/ProposedOrder.java b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/ProposedOrder.java index df1b4ff..18c9c52 100644 --- a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/ProposedOrder.java +++ b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/ProposedOrder.java @@ -131,7 +131,7 @@ public class ProposedOrder { tree = new BOMTree(product.getString("productId"), "MANUF_COMPONENT", requiredByDate, BOMTree.EXPLOSION_SINGLE_LEVEL, delegator, dispatcher, userLogin); tree.setRootQuantity(quantity); tree.print(components, true); - if (components.size() > 0) components.remove(0); + if (!components.isEmpty()) components.remove(0); } catch (Exception exc) { Debug.logWarning(exc.getMessage(), MODULE); tree = null; diff --git a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/techdata/TechDataServices.java b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/techdata/TechDataServices.java index c71c0e9..c30b4fd 100644 --- a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/techdata/TechDataServices.java +++ b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/techdata/TechDataServices.java @@ -183,7 +183,7 @@ public class TechDataServices { } else { try { List<GenericValue> machines = machineGroup.getRelated("ChildFixedAsset", null, null, true); - if (machines != null && machines.size() > 0) { + if (machines != null && !machines.isEmpty()) { GenericValue machine = EntityUtil.getFirst(machines); techDataCalendar = machine.getRelatedOne("TechDataCalendar", true); } diff --git a/applications/marketing/src/main/java/org/apache/ofbiz/marketing/report/ReportHelper.java b/applications/marketing/src/main/java/org/apache/ofbiz/marketing/report/ReportHelper.java index ea93902..21b695d 100644 --- a/applications/marketing/src/main/java/org/apache/ofbiz/marketing/report/ReportHelper.java +++ b/applications/marketing/src/main/java/org/apache/ofbiz/marketing/report/ReportHelper.java @@ -59,7 +59,7 @@ public final class ReportHelper { List<GenericValue> ordersForThisKey = EntityUtil.filterByAnd(orders, UtilMisc.toMap(keyFieldName, visit.getString(keyFieldName))); // if there are matching orders, then calculate orders, order amount, and conversion rate - if ((ordersForThisKey != null) && (ordersForThisKey.size() > 0)) { + if ((ordersForThisKey != null) && (!ordersForThisKey.isEmpty())) { // note: there should be only one line of order stats per key, so .get(0) should work GenericValue orderValue = ordersForThisKey.get(0); diff --git a/applications/marketing/src/main/java/org/apache/ofbiz/marketing/tracking/TrackingCodeEvents.java b/applications/marketing/src/main/java/org/apache/ofbiz/marketing/tracking/TrackingCodeEvents.java index a23cd12..3f9290b 100644 --- a/applications/marketing/src/main/java/org/apache/ofbiz/marketing/tracking/TrackingCodeEvents.java +++ b/applications/marketing/src/main/java/org/apache/ofbiz/marketing/tracking/TrackingCodeEvents.java @@ -240,7 +240,7 @@ public class TrackingCodeEvents { Cookie trackableCookie = new Cookie("TKCDT_" + trackingCode.getString("trackingCodeTypeId"), trackingCode.getString("trackingCodeId")); if (trackableLifetime > 0) trackableCookie.setMaxAge(trackableLifetime.intValue()); trackableCookie.setPath("/"); - if (cookieDomain.length() > 0) trackableCookie.setDomain(cookieDomain); + if (!cookieDomain.isEmpty()) trackableCookie.setDomain(cookieDomain); trackableCookie.setSecure(true); trackableCookie.setHttpOnly(true); response.addCookie(trackableCookie); @@ -253,7 +253,7 @@ public class TrackingCodeEvents { Cookie billableCookie = new Cookie("TKCDB_" + trackingCode.getString("trackingCodeTypeId"), trackingCode.getString("trackingCodeId")); if (billableLifetime > 0) billableCookie.setMaxAge(billableLifetime.intValue()); billableCookie.setPath("/"); - if (cookieDomain.length() > 0) billableCookie.setDomain(cookieDomain); + if (!cookieDomain.isEmpty()) billableCookie.setDomain(cookieDomain); billableCookie.setSecure(true); billableCookie.setHttpOnly(true); response.addCookie(billableCookie); @@ -295,7 +295,7 @@ public class TrackingCodeEvents { Cookie siteIdCookie = new Cookie("Ofbiz.TKCD.SiteId", siteIdEnc); siteIdCookie.setMaxAge(siteIdCookieAge); siteIdCookie.setPath("/"); - if (cookieDomain.length() > 0) siteIdCookie.setDomain(cookieDomain); + if (!cookieDomain.isEmpty()) siteIdCookie.setDomain(cookieDomain); siteIdCookie.setSecure(true); siteIdCookie.setHttpOnly(true); response.addCookie(siteIdCookie); @@ -304,7 +304,7 @@ public class TrackingCodeEvents { Cookie updatedTimeStampCookie = new Cookie("Ofbiz.TKCD.UpdatedTimeStamp", UtilDateTime.nowTimestamp().toString()); updatedTimeStampCookie.setMaxAge(siteIdCookieAge); updatedTimeStampCookie.setPath("/"); - if (cookieDomain.length() > 0) updatedTimeStampCookie.setDomain(cookieDomain); + if (!cookieDomain.isEmpty()) updatedTimeStampCookie.setDomain(cookieDomain); updatedTimeStampCookie.setSecure(true); updatedTimeStampCookie.setHttpOnly(true); response.addCookie(updatedTimeStampCookie); diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderListState.java b/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderListState.java index be01017..c4a9c97 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderListState.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderListState.java @@ -348,10 +348,10 @@ public class OrderListState implements Serializable { EntityCondition statusConditionsList = EntityCondition.makeCondition(statusConditions, EntityOperator.OR); EntityCondition typeConditionsList = EntityCondition.makeCondition(typeConditions, EntityOperator.OR); - if (statusConditions.size() > 0) { + if (!statusConditions.isEmpty()) { allConditions.add(statusConditionsList); } - if (typeConditions.size() > 0) { + if (!typeConditions.isEmpty()) { allConditions.add(typeConditionsList); } diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderLookupServices.java b/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderLookupServices.java index 2bec373..ec32473 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderLookupServices.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderLookupServices.java @@ -579,7 +579,7 @@ public class OrderLookupServices { // create the main condition EntityCondition cond = null; - if (conditions.size() > 0 || "Y".equalsIgnoreCase(showAll)) { + if (!conditions.isEmpty() || "Y".equalsIgnoreCase(showAll)) { cond = EntityCondition.makeCondition(conditions, EntityOperator.AND); } @@ -647,7 +647,7 @@ public class OrderLookupServices { doFilter = "N"; } - if ("Y".equals(doFilter) && orderList.size() > 0) { + if ("Y".equals(doFilter) && !orderList.isEmpty()) { paramList.add("filterInventoryProblems=Y"); for (GenericValue orderHeader : orderList) { OrderReadHelper orh = new OrderReadHelper(orderHeader); @@ -689,7 +689,7 @@ public class OrderLookupServices { doPoFilter = true; } - if (doPoFilter && orderList.size() > 0) { + if (doPoFilter && !orderList.isEmpty()) { for (GenericValue orderHeader : orderList) { OrderReadHelper orh = new OrderReadHelper(orderHeader); String orderType = orh.getOrderTypeId(); diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReadHelper.java b/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReadHelper.java index 55e0c3f..1d75f50 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReadHelper.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReadHelper.java @@ -698,7 +698,7 @@ public class OrderReadHelper { public Timestamp getEarliestShipByDate() { try { List<GenericValue> groups = orderHeader.getRelated("OrderItemShipGroup", null, UtilMisc.toList("shipByDate"), false); - if (groups.size() > 0) { + if (!groups.isEmpty()) { GenericValue group = groups.get(0); return group.getTimestamp("shipByDate"); } @@ -715,7 +715,7 @@ public class OrderReadHelper { public Timestamp getLatestShipAfterDate() { try { List<GenericValue> groups = orderHeader.getRelated("OrderItemShipGroup", null, UtilMisc.toList("shipAfterDate DESC"), false); - if (groups.size() > 0) { + if (!groups.isEmpty()) { GenericValue group = groups.get(0); return group.getTimestamp("shipAfterDate"); } diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReturnServices.java b/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReturnServices.java index d5caec4..2f516c5 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReturnServices.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReturnServices.java @@ -2030,10 +2030,10 @@ public class OrderReturnServices { } } orderMap.put("orderItems", orderItems); - if (orderItemShipGroupInfo.size() > 0) { + if (!orderItemShipGroupInfo.isEmpty()) { orderMap.put("orderItemShipGroupInfo", orderItemShipGroupInfo); } - if (orderItemAssocs.size() > 0) { + if (!orderItemAssocs.isEmpty()) { orderMap.put("orderItemAssociations", orderItemAssocs); } } else { @@ -2104,7 +2104,7 @@ public class OrderReturnServices { parties.add(orderRole.getString("partyId")); } } - if (orderRolesMap.size() > 0) { + if (!orderRolesMap.isEmpty()) { orderMap.put("orderAdditionalPartyRoleMap", orderRolesMap); } } catch (GenericEntityException e) { @@ -2204,7 +2204,7 @@ public class OrderReturnServices { // create a return message AND create ReturnItemResponse record(s) StringBuilder successMessage = new StringBuilder(); - if (createdOrderIds.size() > 0) { + if (!createdOrderIds.isEmpty()) { successMessage.append("The following new orders have been created : "); Iterator<String> i = createdOrderIds.iterator(); while (i.hasNext()) { @@ -2354,7 +2354,7 @@ public class OrderReturnServices { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderErrorGettingReturnHeaderItemInformation", locale)); } - if ((returnItems != null) && (returnItems.size() > 0)) { + if ((returnItems != null) && (!returnItems.isEmpty())) { List<String> paymentList = new LinkedList<>(); for (GenericValue returnItem : returnItems) { String orderId = returnItem.getString("orderId"); diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java b/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java index 955405e..f94281b 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java @@ -158,7 +158,7 @@ public class OrderServices { Debug.logError("Could not determine if " + partyId + " is a customer of user " + userLogin.getString("userLoginId") + " due" + " to " + ex.getMessage(), MODULE); } - if ((repsCustomers != null) && (repsCustomers.size() > 0) && (security.hasEntityPermission("ORDERMGR", "_ROLE_" + action, + if ((repsCustomers != null) && (!repsCustomers.isEmpty()) && (security.hasEntityPermission("ORDERMGR", "_ROLE_" + action, userLogin))) { hasPermission = true; } @@ -171,7 +171,7 @@ public class OrderServices { Debug.logError("Could not determine if " + partyId + " is a customer of user " + userLogin.getString("userLoginId") + " due to " + ex.getMessage(), MODULE); } - if ((repsCustomers != null) && (repsCustomers.size() > 0) && (security.hasEntityPermission("ORDERMGR", "_ROLE_" + action, + if ((repsCustomers != null) && (!repsCustomers.isEmpty()) && (security.hasEntityPermission("ORDERMGR", "_ROLE_" + action, userLogin))) { hasPermission = true; } @@ -211,7 +211,7 @@ public class OrderServices { // jacopoc: what is the meaning of this code block? FIXME if (!hasPermission) { partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, resultSecurity, "ORDERMGR", "_CREATE"); - if (resultSecurity.size() > 0) { + if (!resultSecurity.isEmpty()) { return resultSecurity; } } @@ -435,7 +435,7 @@ public class OrderServices { } } - if (errorMessages.size() > 0) { + if (!errorMessages.isEmpty()) { return ServiceUtil.returnError(errorMessages); } @@ -804,11 +804,11 @@ public class OrderServices { tempList.add(techDataCalendarExcDay); } } - if (tempList.size() > 0) { + if (!tempList.isEmpty()) { toBeStored.addAll(tempList); } } - if (errorMessages.size() > 0) { + if (!errorMessages.isEmpty()) { return ServiceUtil.returnError(errorMessages); } @@ -1143,7 +1143,7 @@ public class OrderServices { return ServiceUtil.returnError(e.getMessage()); } - if (resErrorMessages.size() > 0) { + if (!resErrorMessages.isEmpty()) { return ServiceUtil.returnError(resErrorMessages); } // END inventory reservation @@ -1719,7 +1719,7 @@ public class OrderServices { // no shipping address, try the billing address if (shippingAddress == null) { List<GenericValue> billingAddressList = orh.getBillingLocations(); - if (billingAddressList.size() > 0) { + if (!billingAddressList.isEmpty()) { shippingAddress = billingAddressList.get(0); } } @@ -2425,7 +2425,7 @@ public class OrderServices { } // store the changes - if (toBeStored.size() > 0) { + if (!toBeStored.isEmpty()) { try { delegator.storeAll(toBeStored); } catch (GenericEntityException e) { @@ -3356,7 +3356,7 @@ public class OrderServices { } // now process the digital items - if (digitalItems.size() > 0 || nonProductItems.size() > 0) { + if (!digitalItems.isEmpty() || !nonProductItems.isEmpty()) { GenericValue productStore = OrderReadHelper.getProductStoreFromOrder(dispatcher.getDelegator(), orderId); boolean invoiceItems = true; if (productStore != null && productStore.get("autoInvoiceDigitalItems") != null) { @@ -4700,7 +4700,7 @@ public class OrderServices { throw new GeneralException(e.getMessage()); } - if (resErrorMessages.size() > 0) { + if (!resErrorMessages.isEmpty()) { throw new GeneralException(ServiceUtil.getErrorMessage(ServiceUtil.returnError(resErrorMessages))); } } @@ -6856,7 +6856,7 @@ public class OrderServices { itemConditions.add(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "ALLOC_PLAN_ITEM_APRV")); allocationPlanItems = EntityQuery.use(delegator).from("AllocationPlanItem").where(itemConditions).queryList(); - if (allocationPlanItems.size() > 0) { + if (!allocationPlanItems.isEmpty()) { //Rereserve the inventory serviceCtx.put("productId", productId); serviceCtx.put("facilityId", facilityId); @@ -7378,7 +7378,7 @@ public class OrderServices { itemConditions.add(EntityCondition.makeCondition("planItemSeqId", EntityOperator.IN, reReservePlanItemSeqIdList)); List<GenericValue> allocationPlanItems = EntityQuery.use(delegator).from("AllocationPlanItem").where(itemConditions).queryList(); - if (allocationPlanItems.size() > 0) { + if (!allocationPlanItems.isEmpty()) { //Rereserve the inventory serviceCtx.put("productId", productId); serviceCtx.put("facilityId", facilityId); diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java index c49d58c..50266d5 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java @@ -901,11 +901,11 @@ public class CheckOutEvents { } //See whether we need to return an error or not callResult = ServiceUtil.returnSuccess(); - if (errorMessages.size() > 0) { + if (!errorMessages.isEmpty()) { callResult.put(ModelService.ERROR_MESSAGE_LIST, errorMessages); callResult.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_ERROR); } - if (errorMaps.size() > 0) { + if (!errorMaps.isEmpty()) { callResult.put(ModelService.ERROR_MESSAGE_MAP, errorMaps); callResult.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_ERROR); } @@ -968,7 +968,7 @@ public class CheckOutEvents { // Verify if a gift card has been selected during order entry callResult = checkOutHelper.checkGiftCard(paramMap, selectedPaymentMethods); ServiceUtil.addErrors(errorMessages, errorMaps, callResult); - if (errorMessages.size() == 0 && errorMaps.size() == 0) { + if (errorMessages.isEmpty() && errorMaps.isEmpty()) { String gcPaymentMethodId = (String) callResult.get("paymentMethodId"); BigDecimal giftCardAmount = (BigDecimal) callResult.get("amount"); // WARNING: if gcPaymentMethodId is not empty, all the previously set payment methods will be removed @@ -977,11 +977,11 @@ public class CheckOutEvents { } //See whether we need to return an error or not callResult = ServiceUtil.returnSuccess(); - if (errorMessages.size() > 0) { + if (!errorMessages.isEmpty()) { callResult.put(ModelService.ERROR_MESSAGE_LIST, errorMessages); callResult.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_ERROR); } - if (errorMaps.size() > 0) { + if (!errorMaps.isEmpty()) { callResult.put(ModelService.ERROR_MESSAGE_MAP, errorMaps); callResult.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_ERROR); } diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutHelper.java b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutHelper.java index 740664a..eb5c8e4 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutHelper.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutHelper.java @@ -100,7 +100,7 @@ public class CheckOutHelper { } if (errorMessages.size() == 1) { result = ServiceUtil.returnError(errorMessages.get(0)); - } else if (errorMessages.size() > 0) { + } else if (!errorMessages.isEmpty()) { result = ServiceUtil.returnError(errorMessages); } else { result = ServiceUtil.returnSuccess(); @@ -154,7 +154,7 @@ public class CheckOutHelper { if (errorMessages.size() == 1) { result = ServiceUtil.returnError(errorMessages.get(0)); - } else if (errorMessages.size() > 0) { + } else if (!errorMessages.isEmpty()) { result = ServiceUtil.returnError(errorMessages); } else { result = ServiceUtil.returnSuccess(); @@ -255,7 +255,7 @@ public class CheckOutHelper { if (errorMessages.size() == 1) { result = ServiceUtil.returnError(errorMessages.get(0)); - } else if (errorMessages.size() > 0) { + } else if (!errorMessages.isEmpty()) { result = ServiceUtil.returnError(errorMessages); } else { result = ServiceUtil.returnSuccess(); @@ -418,7 +418,7 @@ public class CheckOutHelper { if (errorMessages.size() == 1) { result = ServiceUtil.returnError(errorMessages.get(0)); - } else if (errorMessages.size() > 0) { + } else if (!errorMessages.isEmpty()) { result = ServiceUtil.returnError(errorMessages); } else { result = ServiceUtil.returnSuccess(); @@ -468,7 +468,7 @@ public class CheckOutHelper { if (errorMessages.size() == 1) { result = ServiceUtil.returnError(errorMessages.get(0)); - } else if (errorMessages.size() > 0) { + } else if (!errorMessages.isEmpty()) { result = ServiceUtil.returnError(errorMessages); } else { result = ServiceUtil.returnSuccess(); @@ -574,7 +574,7 @@ public class CheckOutHelper { if (gcResult != null) { ServiceUtil.addErrors(errorMessages, errorMaps, gcResult); - if (errorMessages.size() == 0 && errorMaps.size() == 0) { + if (errorMessages.isEmpty() && errorMaps.isEmpty()) { // set the GC payment method BigDecimal giftCardAmount = null; if (gcAmount.compareTo(BigDecimal.ZERO) > 0) { @@ -595,11 +595,11 @@ public class CheckOutHelper { } // see whether we need to return an error or not - if (errorMessages.size() > 0) { + if (!errorMessages.isEmpty()) { result.put(ModelService.ERROR_MESSAGE_LIST, errorMessages); result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_ERROR); } - if (errorMaps.size() > 0) { + if (!errorMaps.isEmpty()) { result.put(ModelService.ERROR_MESSAGE_MAP, errorMaps); result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_ERROR); } @@ -823,7 +823,7 @@ public class CheckOutHelper { toBeStored.add(orderContactMech); } - if (toBeStored.size() > 0) { + if (!toBeStored.isEmpty()) { try { if (Debug.verboseOn()) { Debug.logVerbose("To Be Stored: " + toBeStored, MODULE); @@ -1211,7 +1211,7 @@ public class CheckOutHelper { List<GenericValue> productStorePaymentSettingList = EntityQuery.use(delegator).from("ProductStorePaymentSetting") .where("productStoreId", productStore.getString("productStoreId"), "paymentMethodTypeId", "CREDIT_CARD", "paymentService", "cyberSourceCCAuth") .queryList(); - if (productStorePaymentSettingList.size() > 0) { + if (!productStorePaymentSettingList.isEmpty()) { String decision = (String) paymentResult.get("authCode"); if (UtilValidate.isNotEmpty(decision)) { if ("ACCEPT".equalsIgnoreCase(decision)) { @@ -1402,7 +1402,7 @@ public class CheckOutHelper { } List<GenericValue> blacklistFound = null; - if (exprs.size() > 0) { + if (!exprs.isEmpty()) { try { blacklistFound = EntityQuery.use(this.delegator).from("OrderBlacklist").where(exprs).queryList(); } catch (GenericEntityException e) { @@ -1773,7 +1773,7 @@ public class CheckOutHelper { // payment by billing account only requires more checking List<String> paymentMethods = cart.getPaymentMethodIds(); List<String> paymentTypes = cart.getPaymentMethodTypeIds(); - if (paymentTypes.contains("EXT_BILLACT") && paymentTypes.size() == 1 && paymentMethods.size() == 0) { + if (paymentTypes.contains("EXT_BILLACT") && paymentTypes.size() == 1 && paymentMethods.isEmpty()) { if (cart.getGrandTotal().compareTo(availableAmount) > 0) { errMsg = UtilProperties.getMessage(RES_ERROR, "checkevents.insufficient_credit_available_on_account", cart.getLocale()); return ServiceUtil.returnError(errMsg); diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java index 3005257..58c2518 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java @@ -516,7 +516,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return null; } List<GenericValue> productSuppliers = UtilGenerics.cast(result.get("supplierProducts")); - if ((productSuppliers != null) && (productSuppliers.size() > 0)) { + if ((productSuppliers != null) && (!productSuppliers.isEmpty())) { supplierProduct = productSuppliers.get(0); } } catch (GenericServiceException e) { @@ -2650,7 +2650,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { while (csi.hasNext()) { CartShipInfo info = csi.next(); info.shipItemInfo.keySet().removeIf(item -> item.getQuantity().compareTo(BigDecimal.ZERO) == 0); - if (info.shipItemInfo.size() == 0) { + if (info.shipItemInfo.isEmpty()) { csi.remove(); } } @@ -5540,7 +5540,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } } Timestamp estimatedShipDate = null; - if (estimatedShipDates.size() > 0) { + if (!estimatedShipDates.isEmpty()) { estimatedShipDates.sort(null); estimatedShipDate = estimatedShipDates.getLast(); shipGroup.set("estimatedShipDate", estimatedShipDate); diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java index 7835519..4fc6ce7 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java @@ -238,7 +238,7 @@ public class ShoppingCartEvents { } else if (paramMap.containsKey("add_category_id")) { productCategoryId = (String) paramMap.remove("add_category_id"); } - if (productCategoryId != null && productCategoryId.length() == 0) { + if (productCategoryId != null && productCategoryId.isEmpty()) { productCategoryId = null; } @@ -271,7 +271,7 @@ public class ShoppingCartEvents { } else if (paramMap.containsKey("add_item_description")) { itemDescription = (String) paramMap.remove("add_item_description"); } - if (itemDescription != null && itemDescription.length() == 0) { + if (itemDescription != null && itemDescription.isEmpty()) { itemDescription = null; } @@ -365,7 +365,7 @@ public class ShoppingCartEvents { { reservStartStr += " 00:00:00.000000000"; // should have format: yyyy-mm-dd hh:mm:ss.fffffffff } - if (reservStartStr.length() > 0) { + if (!reservStartStr.isEmpty()) { try { reservStart = java.sql.Timestamp.valueOf(reservStartStr); } catch (Exception e) { @@ -386,7 +386,7 @@ public class ShoppingCartEvents { { reservEndStr += " 00:00:00.000000000"; // should have format: yyyy-mm-dd hh:mm:ss.fffffffff } - if (reservEndStr.length() > 0) { + if (!reservEndStr.isEmpty()) { try { reservEnd = java.sql.Timestamp.valueOf(reservEndStr); } catch (Exception e) { @@ -1719,7 +1719,7 @@ public class ShoppingCartEvents { if ("PURCHASE_ORDER".equals(cart.getOrderType())) { cart.setBillFromVendorPartyId(partyId); } - } else if (partyId != null && partyId.length() == 0) { + } else if (partyId != null && partyId.isEmpty()) { cart.setOrderPartyId("_NA_"); partyId = null; } diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartHelper.java b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartHelper.java index e2bb30b..a497c02 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartHelper.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartHelper.java @@ -374,7 +374,7 @@ public class ShoppingCartHelper { } } } - if (errorMsgs.size() > 0) { + if (!errorMsgs.isEmpty()) { result = ServiceUtil.returnError(errorMsgs); result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS); return result; // don't return error because this is a non-critical error and should go back to the same page @@ -652,7 +652,7 @@ public class ShoppingCartHelper { } } } - if (errorMsgs.size() > 0) { + if (!errorMsgs.isEmpty()) { result = ServiceUtil.returnError(errorMsgs); result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS); return result; // don't return error because this is a non-critical error and should go back to the same page @@ -684,7 +684,7 @@ public class ShoppingCartHelper { } } - if (errorMsgs.size() > 0) { + if (!errorMsgs.isEmpty()) { result = ServiceUtil.returnError(errorMsgs); result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS); return result; // don't return error because this is a non-critical error and should go back to the same page @@ -756,7 +756,7 @@ public class ShoppingCartHelper { } else if (parameterName.toUpperCase(Locale.getDefault()).startsWith("COMMENT")) { itemComment = quantString; // the quantString is actually the comment if the field name starts with COMMENT } else if (parameterName.startsWith("reservStart")) { - if (quantString.length() == 0) { + if (quantString.isEmpty()) { // should have format: yyyy-mm-dd hh:mm:ss.fffffffff quantString += " 00:00:00.000000000"; } @@ -1004,7 +1004,7 @@ public class ShoppingCartHelper { // Promotions are run again. ProductPromoWorker.doPromotions(this.cart, dispatcher); - if (errorMsgs.size() > 0) { + if (!errorMsgs.isEmpty()) { result = ServiceUtil.returnError(errorMsgs); return result; } @@ -1106,7 +1106,7 @@ public class ShoppingCartHelper { // set the currency based on the pricing agreement List<GenericValue> agreementItems = agreement.getRelated("AgreementItem", UtilMisc.toMap("agreementItemTypeId", "AGREEMENT_PRICING_PR"), null, false); - if (agreementItems.size() > 0) { + if (!agreementItems.isEmpty()) { GenericValue agreementItem = agreementItems.get(0); String currencyUomId = (String) agreementItem.get("currencyUomId"); if (UtilValidate.isNotEmpty(currencyUomId)) { @@ -1132,7 +1132,7 @@ public class ShoppingCartHelper { cart.removeOrderTerms(); // set order terms based on agreement terms List<GenericValue> agreementTerms = EntityUtil.filterByDate(agreement.getRelated("AgreementTerm", null, null, false)); - if (agreementTerms.size() > 0) { + if (!agreementTerms.isEmpty()) { for (int i = 0; agreementTerms.size() > i; i++) { GenericValue agreementTerm = agreementTerms.get(i); String termTypeId = (String) agreementTerm.get("termTypeId"); diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartServices.java b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartServices.java index 0943381..0302d94 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartServices.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartServices.java @@ -1189,7 +1189,7 @@ public class ShoppingCartServices { String productId = (String) context.get("productId"); if (shoppingCart != null && UtilValidate.isNotEmpty(shoppingCart.items())) { List<ShoppingCartItem> items = shoppingCart.findAllCartItems(productId); - if (items.size() > 0) { + if (!items.isEmpty()) { ShoppingCartItem item = items.get(0); int itemIndex = shoppingCart.getItemIndex(item); result.put("itemIndex", String.valueOf(itemIndex)); diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/product/ProductDisplayWorker.java b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/product/ProductDisplayWorker.java index 5a8ae05..9f276ef 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/product/ProductDisplayWorker.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/product/ProductDisplayWorker.java @@ -300,7 +300,7 @@ public final class ProductDisplayWorker { if (values == null) { return null; } - if (values.size() == 0) { + if (values.isEmpty()) { return values; } diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/product/ProductPromoWorker.java b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/product/ProductPromoWorker.java index d7cd8f1..072a0bc 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/product/ProductPromoWorker.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/product/ProductPromoWorker.java @@ -482,7 +482,7 @@ public final class ProductPromoWorker { enteredCodes.add(orderproductPromoCode.getString("productPromoCodeId")); } } - if (enteredCodes.size() > 0) { + if (!enteredCodes.isEmpty()) { // get all promo codes entered, do a query with an IN condition to see if any of those are related EntityCondition codeCondition = EntityCondition.makeCondition(EntityCondition.makeCondition("productPromoId", EntityOperator.EQUALS, productPromoId), EntityOperator.AND, EntityCondition.makeCondition( @@ -1120,7 +1120,7 @@ public final class ProductPromoWorker { .where("productId", cartItem.getProductId(), "productPriceTypeId", "LIST_PRICE", "productPricePurposeId", "PURCHASE") .orderBy("-fromDate") .filterByDate().queryList(); - GenericValue listProductPrice = (listProductPriceList != null && listProductPriceList.size() > 0) ? listProductPriceList.get(0) : null; + GenericValue listProductPrice = (listProductPriceList != null && !listProductPriceList.isEmpty()) ? listProductPriceList.get(0) : null; BigDecimal listPrice = (listProductPrice != null) ? listProductPrice.getBigDecimal("price") : null; if (listPrice == null) { @@ -1553,11 +1553,11 @@ public final class ProductPromoWorker { while (pcgslmeIter.hasNext()) { Map.Entry<String, List<Set<String>>> entry = pcgslmeIter.next(); List<Set<String>> catIdSetList = entry.getValue(); - if (catIdSetList.size() == 0) { + if (catIdSetList.isEmpty()) { pcgslmeIter.remove(); } else if (catIdSetList.size() == 1) { Set<String> catIdSet = catIdSetList.iterator().next(); - if (catIdSet.size() == 0) { + if (catIdSet.isEmpty()) { pcgslmeIter.remove(); } else { // if there is only one set in the list since the set will be or'ed anyway, just add them all to the productCategoryIds Set diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/test/OrderTestServices.java b/applications/order/src/main/java/org/apache/ofbiz/order/test/OrderTestServices.java index ce90bcd..6a3da4a 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/test/OrderTestServices.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/test/OrderTestServices.java @@ -114,7 +114,7 @@ public class OrderTestServices { } catch (GenericServiceException gse) { return ServiceUtil.returnError(gse.getMessage()); } - if (productsList.size() == 0) { + if (productsList.isEmpty()) { return ServiceUtil.returnError(UtilProperties.getMessage("OrderUiLabels", "OrderCreateTestSalesOrderSingleError", UtilMisc.toMap("productCategoryId", productCategoryId), locale)); diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/thirdparty/taxware/TaxwareUTL.java b/applications/order/src/main/java/org/apache/ofbiz/order/thirdparty/taxware/TaxwareUTL.java index e772ccc..f2b6c0c 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/thirdparty/taxware/TaxwareUTL.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/thirdparty/taxware/TaxwareUTL.java @@ -272,7 +272,7 @@ public class TaxwareUTL { throw new TaxwareException("Shipping amount has not been set."); if (shipToAddress == null) throw new TaxwareException("Shipping address has not been set."); - if (records.size() == 0) + if (records.isEmpty()) throw new TaxwareException("No items have been defined."); } @@ -391,7 +391,7 @@ public class TaxwareUTL { // add a list of adjustments to the adjustment list itemAdjustments.add(currentItem); - } else if (orderAdjustments.size() == 0) { + } else if (orderAdjustments.isEmpty()) { if (rec.getBigDecimal("TAX_AMT_COUNTRY").compareTo(BigDecimal.ZERO) > 0) { BigDecimal rate = rec.getBigDecimal("TAX_RATE_COUNTRY").movePointRight(2); String type = "S".equals(rec.getString("TAX_TYPE_COUNTRY")) ? "SALES TAX" : "USE TAX"; diff --git a/applications/party/src/main/java/org/apache/ofbiz/party/communication/CommunicationEventServices.java b/applications/party/src/main/java/org/apache/ofbiz/party/communication/CommunicationEventServices.java index bdba2c9..092e796 100644 --- a/applications/party/src/main/java/org/apache/ofbiz/party/communication/CommunicationEventServices.java +++ b/applications/party/src/main/java/org/apache/ofbiz/party/communication/CommunicationEventServices.java @@ -263,7 +263,7 @@ public class CommunicationEventServices { } // If there were errors, then the result of this service should be error with the full list of messages - if (errorMessages.size() > 0) { + if (!errorMessages.isEmpty()) { result = ServiceUtil.returnError(errorMessages); } return result; @@ -374,7 +374,7 @@ public class CommunicationEventServices { errorMessages.add(UtilProperties.getMessage(RESOURCE, "commeventservices.communication_event_not_without_content", locale)); } - if (errorMessages.size() > 0) { + if (!errorMessages.isEmpty()) { communicationEvent.set("statusId", "COM_BOUNCED"); communicationEvent.set("note", errorMessages.toString()); communicationEvent.store(); @@ -395,7 +395,7 @@ public class CommunicationEventServices { } catch (GenericEntityException | GenericServiceException e) { return ServiceUtil.returnError(e.getMessage()); } - if (errorMessages.size() > 0) { + if (!errorMessages.isEmpty()) { return ServiceUtil.returnFailure(errorMessages); } return ServiceUtil.returnSuccess(); @@ -631,7 +631,7 @@ public class CommunicationEventServices { return ServiceUtil.returnError(fatalGEE.getMessage()); } - return errorMessages.size() == 0 ? ServiceUtil.returnSuccess() : ServiceUtil.returnError(errorMessages); + return errorMessages.isEmpty() ? ServiceUtil.returnSuccess() : ServiceUtil.returnError(errorMessages); } public static Map<String, Object> setCommEventComplete(DispatchContext dctx, Map<String, ? extends Object> context) { @@ -1198,7 +1198,7 @@ public class CommunicationEventServices { List<String> attachmentIndexes = wrapper.getAttachmentIndexes(); List<String> currentAttachmentNames = getCommEventAttachmentNames(delegator, communicationEventId); - if (attachmentIndexes.size() > 0) { + if (!attachmentIndexes.isEmpty()) { Debug.logInfo("=== message has attachments [" + attachmentIndexes.size() + "] =====", MODULE); for (String attachmentIdx : attachmentIndexes) { String attFileName = wrapper.getPartFilename(attachmentIdx); @@ -1544,7 +1544,7 @@ public class CommunicationEventServices { Debug.logInfo("### MESSAGE ###\n\n" + wrapper.getMessageBody(), MODULE); List<String> attachmentIndexes = wrapper.getAttachmentIndexes(); - if (attachmentIndexes.size() > 0) { + if (!attachmentIndexes.isEmpty()) { Debug.logInfo("### ATTACHMENTS ###", MODULE); for (String idx : attachmentIndexes) { Debug.logInfo("### -- Filename : " + wrapper.getPartFilename(idx), MODULE); diff --git a/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechServices.java b/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechServices.java index dbb8a55..27d1a1a 100644 --- a/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechServices.java +++ b/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechServices.java @@ -79,7 +79,7 @@ public class ContactMechServices { String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PARTYMGR", "_PCM_CREATE"); - if (result.size() > 0) { + if (!result.isEmpty()) { return result; } @@ -144,7 +144,7 @@ public class ContactMechServices { String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PARTYMGR", "_PCM_UPDATE"); - if (result.size() > 0) { + if (!result.isEmpty()) { return result; } @@ -279,7 +279,7 @@ public class ContactMechServices { String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PARTYMGR", "_PCM_DELETE"); - if (result.size() > 0) { + if (!result.isEmpty()) { return result; } @@ -340,7 +340,7 @@ public class ContactMechServices { String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PARTYMGR", "_PCM_CREATE"); - if (result.size() > 0) { + if (!result.isEmpty()) { return result; } @@ -414,7 +414,7 @@ public class ContactMechServices { String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PARTYMGR", "_PCM_UPDATE"); - if (result.size() > 0) { + if (!result.isEmpty()) { return result; } @@ -585,7 +585,7 @@ public class ContactMechServices { String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PARTYMGR", "_PCM_CREATE"); - if (result.size() > 0) { + if (!result.isEmpty()) { return result; } @@ -641,7 +641,7 @@ public class ContactMechServices { String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PARTYMGR", "_PCM_UPDATE"); - if (result.size() > 0) { + if (!result.isEmpty()) { return result; } @@ -822,7 +822,7 @@ public class ContactMechServices { String errMsg = null; Locale locale = (Locale) context.get("locale"); - if (result.size() > 0) { + if (!result.isEmpty()) { return result; } diff --git a/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechWorker.java b/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechWorker.java index 0144ce0..9eb4849 100644 --- a/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechWorker.java +++ b/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechWorker.java @@ -386,7 +386,7 @@ public class ContactMechWorker { purposeTypes.add(contactMechPurposeType); } } - if (purposeTypes.size() > 0) { + if (!purposeTypes.isEmpty()) { target.put("purposeTypes", purposeTypes); } } @@ -657,7 +657,7 @@ public class ContactMechWorker { purposeTypes.add(contactMechPurposeType); } } - if (purposeTypes.size() > 0) { + if (!purposeTypes.isEmpty()) { target.put("purposeTypes", purposeTypes); } } diff --git a/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java b/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java index 7442183..7d968a5 100644 --- a/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java +++ b/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java @@ -716,7 +716,7 @@ public class PartyServices { String email = (String) context.get("email"); Locale locale = (Locale) context.get("locale"); - if (email.length() == 0) { + if (email.isEmpty()) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "partyservices.required_parameter_email_cannot_be_empty", locale)); } @@ -746,7 +746,7 @@ public class PartyServices { "partyservices.cannot_get_party_entities_read", UtilMisc.toMap("errMessage", e.getMessage()), locale)); } - if (parties.size() > 0) { + if (!parties.isEmpty()) { result.put("parties", parties); } return result; @@ -759,7 +759,7 @@ public class PartyServices { String email = (String) context.get("email"); Locale locale = (Locale) context.get("locale"); - if (email.length() == 0) { + if (email.isEmpty()) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "partyservices.required_parameter_email_cannot_be_empty", locale)); } @@ -789,7 +789,7 @@ public class PartyServices { "partyservices.cannot_get_party_entities_read", UtilMisc.toMap("errMessage", e.getMessage()), locale)); } - if (parties.size() > 0) { + if (!parties.isEmpty()) { result.put("parties", parties); } return result; @@ -809,7 +809,7 @@ public class PartyServices { String userLoginId = (String) context.get("userLoginId"); Locale locale = (Locale) context.get("locale"); - if (userLoginId.length() == 0) { + if (userLoginId.isEmpty()) { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "PartyCannotGetUserLoginFromParty", locale)); } @@ -864,7 +864,7 @@ public class PartyServices { if (lastName == null) { lastName = ""; } - if (firstName.length() == 0 && lastName.length() == 0) { + if (firstName.isEmpty() && lastName.isEmpty()) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "partyservices.both_names_cannot_be_empty", locale)); } @@ -892,7 +892,7 @@ public class PartyServices { "partyservices.cannot_get_party_entities_read", UtilMisc.toMap("errMessage", e.getMessage()), locale)); } - if (parties.size() > 0) { + if (!parties.isEmpty()) { result.put("parties", parties); } return result; @@ -911,7 +911,7 @@ public class PartyServices { String groupName = (String) context.get("groupName"); Locale locale = (Locale) context.get("locale"); - if (groupName.length() == 0) { + if (groupName.isEmpty()) { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "PartyCannotgetPartiesFromPartyGroup", locale)); } @@ -937,7 +937,7 @@ public class PartyServices { "partyservices.cannot_get_party_entities_read", UtilMisc.toMap("errMessage", e.getMessage()), locale)); } - if (parties.size() > 0) { + if (!parties.isEmpty()) { result.put("parties", parties); } return result; @@ -1429,7 +1429,7 @@ public class PartyServices { // ---- End of Dynamic View Creation // build the main condition - if (andExprs.size() > 0) { + if (!andExprs.isEmpty()) { mainCond = EntityCondition.makeCondition(andExprs, EntityOperator.AND); } } @@ -2309,7 +2309,7 @@ public class PartyServices { List<GenericValue> currencyCheck = EntityQuery.use(delegator).from("Uom") .where("abbreviation", rec.get("preferredCurrencyUomId"), "uomTypeId", "CURRENCY_MEASURE") .queryList(); - if (UtilValidate.isNotEmpty(rec.get("preferredCurrencyUomId")) && currencyCheck.size() == 0) { + if (UtilValidate.isNotEmpty(rec.get("preferredCurrencyUomId")) && currencyCheck.isEmpty()) { newErrMsgs.add("Line number " + rec.getRecordNumber() + ": partyId: " + currentPartyId + "Currency code not found for: " + rec.get("preferredCurrencyUomId")); } @@ -2342,7 +2342,7 @@ public class PartyServices { List<GenericValue> countryCheck = EntityQuery.use(delegator).from("Geo") .where("geoTypeId", "COUNTRY", "abbreviation", rec.get("countryGeoId")) .queryList(); - if (countryCheck.size() == 0) { + if (countryCheck.isEmpty()) { newErrMsgs.add("Line number " + rec.getRecordNumber() + " partyId: " + currentPartyId + " Invalid Country code: " + rec.get("countryGeoId")); } @@ -2356,7 +2356,7 @@ public class PartyServices { List<GenericValue> stateCheck = EntityQuery.use(delegator).from("Geo") .where("geoTypeId", "STATE", "abbreviation", rec.get("stateProvinceGeoId")) .queryList(); - if (stateCheck.size() == 0) { + if (stateCheck.isEmpty()) { newErrMsgs.add("Line number " + rec.getRecordNumber() + " partyId: " + currentPartyId + " Invalid stateProvinceGeoId code: " + rec.get("countryGeoId")); } @@ -2375,11 +2375,11 @@ public class PartyServices { } } - if (errMsgs.size() == 0) { + if (errMsgs.isEmpty()) { List<GenericValue> partyCheck = EntityQuery.use(delegator).from("PartyIdentification") .where("partyIdentificationTypeId", "PARTY_IMPORT", "idValue", rec.get("partyId")) .queryList(); - addParty = partyCheck.size() == 0; + addParty = partyCheck.isEmpty(); if (!addParty) { // update party newPartyId = EntityUtil.getFirst(partyCheck).getString("partyId"); @@ -2452,7 +2452,7 @@ public class PartyServices { List<GenericValue> companyCheck = EntityQuery.use(delegator).from("PartyIdentification") .where("partyIdentificationTypeId", "PARTY_IMPORT", "idValue", rec.get("partyId")) .queryList(); - if (companyCheck.size() == 0) { // update party group + if (companyCheck.isEmpty()) { // update party group // company does not exist so create Map<String, Object> companyPartyGroup = UtilMisc.toMap( "partyId", newCompanyPartyId, "statusId", "PARTY_ENABLED", "userLogin", userLogin); @@ -2552,7 +2552,7 @@ public class PartyServices { lastContactMechPurposeTypeId = currentContactMechPurposeTypeId; // update - if (errMsgs.size() == 0) { + if (errMsgs.isEmpty()) { if (postalAddressChanged) { result = dispatcher.runSync("createPostalAddress", postalAddress); @@ -2619,7 +2619,7 @@ public class PartyServices { return ServiceUtil.returnError(e.getMessage()); } - if (errMsgs.size() > 0) { + if (!errMsgs.isEmpty()) { return ServiceUtil.returnError(errMsgs); } diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/catalog/CatalogWorker.java b/applications/product/src/main/java/org/apache/ofbiz/product/catalog/CatalogWorker.java index b5c118e..27c06f0 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/catalog/CatalogWorker.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/catalog/CatalogWorker.java @@ -201,7 +201,7 @@ public final class CatalogWorker { if (partyCatalogs != null) allCatalogLinks.addAll(partyCatalogs); if (storeCatalogs != null) allCatalogLinks.addAll(storeCatalogs); - if (allCatalogLinks.size() > 0) { + if (!allCatalogLinks.isEmpty()) { for (GenericValue catalogLink: allCatalogLinks) { categoryIds.add(catalogLink.getString("prodCatalogId")); } diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlFilter.java b/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlFilter.java index 122ec05..8e67c8a 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlFilter.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlFilter.java @@ -281,7 +281,7 @@ public class CatalogUrlFilter implements Filter { // adjust trail String previousCategoryId = null; - if (trail.size() > 0) { + if (!trail.isEmpty()) { previousCategoryId = trail.get(trail.size() - 1); } trail = CategoryWorker.adjustTrail(trail, productCategoryId, previousCategoryId); diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryServices.java b/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryServices.java index 20f89a6..157791b 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryServices.java @@ -169,7 +169,7 @@ public class CategoryServices { if (orderByFields == null) { return entityName; } - if (orderByFields.size() == 0) { + if (orderByFields.isEmpty()) { orderByFields.add("sequenceNum"); orderByFields.add("productId"); } diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoContentUrlFilter.java b/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoContentUrlFilter.java index 24f0982..27bb0b0 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoContentUrlFilter.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoContentUrlFilter.java @@ -66,11 +66,11 @@ public class SeoContentUrlFilter implements Filter { if (alternativeUrl.endsWith("-content")) { try { List<GenericValue> contentDataResourceViews = EntityQuery.use(delegator).from("ContentDataResourceView").where("drObjectInfo", alternativeUrl).queryList(); - if (contentDataResourceViews.size() > 0) { + if (!contentDataResourceViews.isEmpty()) { contentDataResourceViews = EntityUtil.orderBy(contentDataResourceViews, UtilMisc.toList("createdDate DESC")); GenericValue contentDataResourceView = EntityUtil.getFirst(contentDataResourceViews); List<GenericValue> contents = EntityQuery.use(delegator).from("ContentAssoc").where("contentAssocTypeId", "ALTERNATIVE_URL", "contentIdTo", contentDataResourceView.getString("contentId")).filterByDate().queryList(); - if (contents.size() > 0) { + if (!contents.isEmpty()) { GenericValue content = EntityUtil.getFirst(contents); urlContentId = content.getString("contentId"); } diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/CatalogUrlSeoTransform.java b/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/CatalogUrlSeoTransform.java index 9263e97..35033eb 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/CatalogUrlSeoTransform.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/CatalogUrlSeoTransform.java @@ -579,7 +579,7 @@ public class CatalogUrlSeoTransform implements TemplateTransformModel { EntityCondition.makeCondition(exprs, EntityOperator.OR), UtilMisc.toSet("productId", "productName"), null, null, true); - if (products != null && products.size() > 0) { + if (products != null && !products.isEmpty()) { if (products.size() == 1) { productId = products.get(0).getString("productId"); break; diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWorker.java b/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWorker.java index 80149d4..209c93f 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWorker.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWorker.java @@ -218,7 +218,7 @@ public final class ProductConfigWorker { } } - if (selectedOptions.size() > 0) { + if (!selectedOptions.isEmpty()) { selectedOptionSize += selectedOptions.size(); configItemId = ci.getConfigItemAssoc().getString("configItemId"); sequenceNum = ci.getConfigItemAssoc().getLong("sequenceNum"); @@ -340,7 +340,7 @@ public final class ProductConfigWorker { } } - if (selectedOptions.size() > 0) { + if (!selectedOptions.isEmpty()) { if (nextId) { configId = delegator.getNextSeqId("ProductConfigConfig"); //get next configId only once and only if there are selectedOptions diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java b/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java index 5b2abc7..47fd48a 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java @@ -216,7 +216,7 @@ public class ProductConfigWrapper implements Serializable { ConfigOption co = ci.getDefault(); if (co != null) { co.setSelected(true); - } else if (ci.getOptions().size() > 0) { + } else if (!ci.getOptions().isEmpty()) { co = ci.getOptions().get(0); co.setSelected(true); } diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/feature/ProductFeatureServices.java b/applications/product/src/main/java/org/apache/ofbiz/product/feature/ProductFeatureServices.java index bfde8b7..4dd3222 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/feature/ProductFeatureServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/feature/ProductFeatureServices.java @@ -206,7 +206,7 @@ public class ProductFeatureServices { List<Map<String, Object>> combinations; // start with either existing combinations or from scratch - if (oldCombinations.size() > 0) { + if (!oldCombinations.isEmpty()) { combinations = oldCombinations; } else { combinations = new LinkedList<>(); @@ -216,7 +216,7 @@ public class ProductFeatureServices { // product feature and add it to the id code and product feature applications // of the next variant. just a matter of whether we're starting with an // existing list of features and id code or from scratch. - if (combinations.size() == 0) { + if (combinations.isEmpty()) { for (GenericValue currentFeature: currentFeatures) { if ("SELECTABLE_FEATURE".equals(currentFeature.getString("productFeatureApplTypeId"))) { Map<String, Object> newCombination = new HashMap<>(); @@ -310,7 +310,7 @@ public class ProductFeatureServices { } List<GenericValue> memberProducts = UtilGenerics.cast(result.get("categoryMembers")); - if ((memberProducts != null) && (memberProducts.size() > 0)) { + if ((memberProducts != null) && (!memberProducts.isEmpty())) { // construct a Map of productFeatureTypeId -> productFeatureId from the productFeatures List Map<String, String> featuresByType = new HashMap<>(); for (GenericValue nextFeature: productFeatures) { @@ -329,14 +329,14 @@ public class ProductFeatureServices { } List<GenericValue> variantProducts = UtilGenerics.cast(result.get("products")); - if ((variantProducts != null) && (variantProducts.size() > 0)) { + if ((variantProducts != null) && (!variantProducts.isEmpty())) { products.addAll(variantProducts); } else { Debug.logWarning("Product " + memberProduct.getString("productId") + " did not have any variants for the given features", MODULE); } } - if (products.size() == 0) { + if (products.isEmpty()) { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ProductCategoryNoVariants", locale)); } else { results = ServiceUtil.returnSuccess(); diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/ImageManagementServices.java b/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/ImageManagementServices.java index b8d4194..94a3e5f 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/ImageManagementServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/ImageManagementServices.java @@ -839,7 +839,7 @@ public class ImageManagementServices { } List<GenericValue> contentAssocList = EntityQuery.use(delegator).from("ContentAssoc").where("contentId", contentId, "contentAssocTypeId", "IMAGE_THUMBNAIL").queryList(); - if (contentAssocList.size() > 0) { + if (!contentAssocList.isEmpty()) { for (int i = 0; i < contentAssocList.size(); i++) { GenericValue contentAssoc = contentAssocList.get(i); diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/ReplaceImage.java b/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/ReplaceImage.java index 8516077..4fbbc3a 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/ReplaceImage.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/ReplaceImage.java @@ -83,7 +83,7 @@ public class ReplaceImage { ImageIO.write(bufImg, "jpg", new File(imageServerPath + "/" + productId + "/" + dataResourceNameExist)); List<GenericValue> contentAssocReplaceList = EntityQuery.use(delegator).from("ContentAssoc").where("contentId", contentIdReplace, "contentAssocTypeId", "IMAGE_THUMBNAIL").queryList(); - if (contentAssocReplaceList.size() > 0) { + if (!contentAssocReplaceList.isEmpty()) { for (int i = 0; i < contentAssocReplaceList.size(); i++) { GenericValue contentAssocReplace = contentAssocReplaceList.get(i); diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/inventory/InventoryServices.java b/applications/product/src/main/java/org/apache/ofbiz/product/inventory/InventoryServices.java index a075bad..ddf92e0 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/inventory/InventoryServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/inventory/InventoryServices.java @@ -655,7 +655,7 @@ public class InventoryServices { } toBeStored.add(orderItem); } - if (toBeStored.size() > 0) { + if (!toBeStored.isEmpty()) { try { delegator.storeAll(toBeStored); } catch (GenericEntityException e) { diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/inventory/InventoryWorker.java b/applications/product/src/main/java/org/apache/ofbiz/product/inventory/InventoryWorker.java index 3c4b8c5..bce3b07 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/inventory/InventoryWorker.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/inventory/InventoryWorker.java @@ -116,7 +116,7 @@ public final class InventoryWorker { EntityCondition.makeCondition("orderStatusId", EntityOperator.NOT_EQUAL, "ORDER_COMPLETED"), EntityCondition.makeCondition("orderStatusId", EntityOperator.NOT_EQUAL, "ORDER_REJECTED"), EntityCondition.makeCondition("orderStatusId", EntityOperator.NOT_EQUAL, "ORDER_CANCELLED")); - if (productIds.size() > 0) { + if (!productIds.isEmpty()) { condList.add(EntityCondition.makeCondition("productId", EntityOperator.IN, productIds)); } condList.add(EntityCondition.makeCondition("orderItemStatusId", EntityOperator.NOT_EQUAL, "ITEM_COMPLETED")); diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/price/PriceServices.java b/applications/product/src/main/java/org/apache/ofbiz/product/price/PriceServices.java index cae0bca..8f64731 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/price/PriceServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/price/PriceServices.java @@ -121,7 +121,7 @@ public class PriceServices { // no ProductStore.primaryStoreGroupId, try ProductStoreGroupMember List<GenericValue> productStoreGroupMemberList = EntityQuery.use(delegator).from("ProductStoreGroupMember").where("productStoreId", productStoreId).orderBy("sequenceNum", "-fromDate").cache(true).queryList(); productStoreGroupMemberList = EntityUtil.filterByDate(productStoreGroupMemberList, true); - if (productStoreGroupMemberList.size() > 0) { + if (!productStoreGroupMemberList.isEmpty()) { GenericValue productStoreGroupMember = EntityUtil.getFirst(productStoreGroupMemberList); productStoreGroupId = productStoreGroupMember.getString("productStoreGroupId"); } diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/product/KeywordIndex.java b/applications/product/src/main/java/org/apache/ofbiz/product/product/KeywordIndex.java index c67dcaf..7ac8c90 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/product/KeywordIndex.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/product/KeywordIndex.java @@ -201,7 +201,7 @@ public class KeywordIndex { toBeStored.add(productKeyword); } } - if (toBeStored.size() > 0) { + if (!toBeStored.isEmpty()) { if (Debug.verboseOn()) { Debug.logVerbose("[KeywordIndex.indexKeywords] Storing " + toBeStored.size() + " keywords for productId " + product.getString("productId"), MODULE); } diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductEvents.java b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductEvents.java index d7bcd8e..2b67c6a 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductEvents.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductEvents.java @@ -255,7 +255,7 @@ public class ProductEvents { if (!"CREATE".equals(updateMode) && UtilValidate.isEmpty(fromDateStr)) { errMsgList.add(UtilProperties.getMessage(RESOURCE, "productevents.from_date_missing", UtilHttp.getLocale(request))); } - if (errMsgList.size() > 0) { + if (!errMsgList.isEmpty()) { request.setAttribute("_ERROR_MESSAGE_LIST_", errMsgList); return "error"; } @@ -326,7 +326,7 @@ public class ProductEvents { errMsgList.add(UtilProperties.getMessage(RESOURCE, "productevents.sequenceNum_not_formatted_correctly", UtilHttp.getLocale(request))); } } - if (errMsgList.size() > 0) { + if (!errMsgList.isEmpty()) { request.setAttribute("_ERROR_MESSAGE_LIST_", errMsgList); return "error"; } @@ -550,7 +550,7 @@ public class ProductEvents { if (numberSpecified != null && !foundOneEqual) { String productFeatureId = null; List<GenericValue> existingProductFeatureList = EntityQuery.use(delegator).from("ProductFeature").where("productFeatureTypeId", productFeatureTypeId, "numberSpecified", numberSpecified, "uomId", uomId).queryList(); - if (existingProductFeatureList.size() > 0) { + if (!existingProductFeatureList.isEmpty()) { GenericValue existingProductFeature = existingProductFeatureList.get(0); productFeatureId = existingProductFeature.getString("productFeatureId"); } else { @@ -662,7 +662,7 @@ public class ProductEvents { Set<String> descriptionsForThisType = new HashSet<>(); List<GenericValue> productFeatureAndApplList = EntityQuery.use(delegator).from("ProductFeatureAndAppl").where("productId", productId, "productFeatureApplTypeId", productFeatureApplTypeId, "productFeatureTypeId", productFeatureTypeId).filterByDate().queryList(); - if (productFeatureAndApplList.size() > 0) { + if (!productFeatureAndApplList.isEmpty()) { Iterator<GenericValue> productFeatureAndApplIter = productFeatureAndApplList.iterator(); while (productFeatureAndApplIter.hasNext()) { productFeatureAndAppl = productFeatureAndApplIter.next(); @@ -684,7 +684,7 @@ public class ProductEvents { GenericValue variant = variantIter.next(); // get the selectable features for the variant List<GenericValue> variantProductFeatureAndAppls = variant.getRelated("ProductFeatureAndAppl", UtilMisc.toMap("productFeatureTypeId", productFeatureTypeId, "productFeatureApplTypeId", "STANDARD_FEATURE", "description", description), null, false); - if (variantProductFeatureAndAppls.size() > 0) { + if (!variantProductFeatureAndAppls.isEmpty()) { foundFeatureOnVariant = true; } } @@ -714,7 +714,7 @@ public class ProductEvents { // see if a feature exists with the type and description specified (if doesn't exist will create later) String productFeatureId = null; List<GenericValue> existingProductFeatureList = EntityQuery.use(delegator).from("ProductFeature").where("productFeatureTypeId", productFeatureTypeId, "description", description).queryList(); - if (existingProductFeatureList.size() > 0) { + if (!existingProductFeatureList.isEmpty()) { GenericValue existingProductFeature = existingProductFeatureList.get(0); productFeatureId = existingProductFeature.getString("productFeatureId"); } else { @@ -740,7 +740,7 @@ public class ProductEvents { // check to see if the productFeatureId is already attached to the virtual or variant, if not attach them... List<GenericValue> specificProductFeatureApplList = EntityQuery.use(delegator).from("ProductFeatureAppl").where("productId", productId, "productFeatureApplTypeId", productFeatureApplTypeId, "productFeatureId", productFeatureId).filterByDate().queryList(); - if (specificProductFeatureApplList.size() == 0) { + if (specificProductFeatureApplList.isEmpty()) { delegator.create("ProductFeatureAppl", UtilMisc.toMap("productId", productId, "productFeatureId", productFeatureId, @@ -818,7 +818,7 @@ public class ProductEvents { for (String categoryId: categoryIds) { try { List<GenericValue> catMembs = EntityQuery.use(delegator).from("ProductCategoryMember").where("productCategoryId", categoryId, "productId", productId).filterByDate().queryList(); - if (catMembs.size() == 0) { + if (catMembs.isEmpty()) { delegator.create("ProductCategoryMember", UtilMisc.toMap("productCategoryId", categoryId, "productId", productId, "fromDate", fromDate)); } @@ -838,12 +838,12 @@ public class ProductEvents { String productId = request.getParameter("productId"); String productCategoryId = request.getParameter("productCategoryId"); String thruDate = request.getParameter("thruDate"); - if ((thruDate == null) || (thruDate.trim().length() == 0)) { + if ((thruDate == null) || (thruDate.trim().isEmpty())) { thruDate = UtilDateTime.nowTimestamp().toString(); } try { List<GenericValue> prodCatMembs = EntityQuery.use(delegator).from("ProductCategoryMember").where("productCategoryId", productCategoryId, "productId", productId).filterByDate().queryList(); - if (prodCatMembs.size() > 0) { + if (!prodCatMembs.isEmpty()) { // there is one to modify GenericValue prodCatMemb = prodCatMembs.get(0); prodCatMemb.setString("thruDate", thruDate); @@ -873,7 +873,7 @@ public class ProductEvents { for (String productFeatureId: productFeatureIdArray) { if (!"~~any~~".equals(productFeatureId)) { List<GenericValue> featureAppls = EntityQuery.use(delegator).from("ProductFeatureAppl").where("productId", productId, "productFeatureId", productFeatureId, "productFeatureApplTypeId", productFeatureApplTypeId).queryList(); - if (featureAppls.size() == 0) { + if (featureAppls.isEmpty()) { // no existing application for this delegator.create("ProductFeatureAppl", UtilMisc.toMap("productId", productId, diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearch.java b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearch.java index 6c1a5fd..f286a0f 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearch.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearch.java @@ -302,7 +302,7 @@ public class ProductSearch { } public void finishKeywordConstraints() { - if (orKeywordFixedSet.size() == 0 && andKeywordFixedSet.size() == 0 && keywordFixedOrSetAndList.size() == 0) { + if (orKeywordFixedSet.isEmpty() && andKeywordFixedSet.isEmpty() && keywordFixedOrSetAndList.isEmpty()) { return; } @@ -310,7 +310,7 @@ public class ProductSearch { this.includedKeywordSearch = true; // if there is anything in the orKeywordFixedSet add it to the keywordFixedOrSetAndList - if (orKeywordFixedSet.size() > 0) { + if (!orKeywordFixedSet.isEmpty()) { // put in keywordFixedOrSetAndList to process with other or lists where at least one is required keywordFixedOrSetAndList.add(orKeywordFixedSet); } @@ -319,7 +319,7 @@ public class ProductSearch { Iterator<Set<String>> keywordFixedOrSetAndTestIter = keywordFixedOrSetAndList.iterator(); while (keywordFixedOrSetAndTestIter.hasNext()) { Set<String> keywordFixedOrSet = keywordFixedOrSetAndTestIter.next(); - if (keywordFixedOrSet.size() == 0) { + if (keywordFixedOrSet.isEmpty()) { keywordFixedOrSetAndTestIter.remove(); } else if (keywordFixedOrSet.size() == 1) { // treat it as just another and @@ -328,12 +328,12 @@ public class ProductSearch { } } - boolean doingBothAndOr = (keywordFixedOrSetAndList.size() > 1) || (keywordFixedOrSetAndList.size() > 0 && andKeywordFixedSet.size() > 0); + boolean doingBothAndOr = (keywordFixedOrSetAndList.size() > 1) || (!keywordFixedOrSetAndList.isEmpty() && !andKeywordFixedSet.isEmpty()); Debug.logInfo("Finished initial setup of keywords, doingBothAndOr=" + doingBothAndOr + ", andKeywordFixedSet=" + andKeywordFixedSet + "\n keywordFixedOrSetAndList=" + keywordFixedOrSetAndList, MODULE); ComplexAlias relevancyComplexAlias = new ComplexAlias("+"); - if (andKeywordFixedSet.size() > 0) { + if (!andKeywordFixedSet.isEmpty()) { // add up the relevancyWeight fields from all keyword member entities for a total to sort by for (String keyword: andKeywordFixedSet) { @@ -386,7 +386,7 @@ public class ProductSearch { dynamicViewEntity.addAlias(null, "totalRelevancy", null, null, null, null, null, relevancyComplexAlias); } } - if (keywordFixedOrSetAndList.size() > 0) { + if (!keywordFixedOrSetAndList.isEmpty()) { for (Set<String> keywordFixedOrSet: keywordFixedOrSetAndList) { // make index based values and increment String entityAlias = "PK" + index; @@ -416,12 +416,12 @@ public class ProductSearch { } public void finishCategoryAndFeatureConstraints() { - if (includeCategoryIds.size() == 0 && excludeCategoryIds.size() == 0 && alwaysIncludeCategoryIds.size() == 0 - && includeCategoryIdOrSetAndList.size() == 0 && alwaysIncludeCategoryIdOrSetAndList.size() == 0 - && includeFeatureIds.size() == 0 && excludeFeatureIds.size() == 0 && alwaysIncludeFeatureIds.size() == 0 - && includeFeatureIdOrSetAndList.size() == 0 && alwaysIncludeFeatureIdOrSetAndList.size() == 0 - && includeFeatureCategoryIds.size() == 0 && excludeFeatureCategoryIds.size() == 0 && alwaysIncludeFeatureCategoryIds.size() == 0 - && includeFeatureGroupIds.size() == 0 && excludeFeatureGroupIds.size() == 0 && alwaysIncludeFeatureGroupIds.size() == 0) { + if (includeCategoryIds.isEmpty() && excludeCategoryIds.isEmpty() && alwaysIncludeCategoryIds.isEmpty() + && includeCategoryIdOrSetAndList.isEmpty() && alwaysIncludeCategoryIdOrSetAndList.isEmpty() + && includeFeatureIds.isEmpty() && excludeFeatureIds.isEmpty() && alwaysIncludeFeatureIds.isEmpty() + && includeFeatureIdOrSetAndList.isEmpty() && alwaysIncludeFeatureIdOrSetAndList.isEmpty() + && includeFeatureCategoryIds.isEmpty() && excludeFeatureCategoryIds.isEmpty() && alwaysIncludeFeatureCategoryIds.isEmpty() + && includeFeatureGroupIds.isEmpty() && excludeFeatureGroupIds.isEmpty() && alwaysIncludeFeatureGroupIds.isEmpty()) { return; } @@ -436,7 +436,7 @@ public class ProductSearch { EntityCondition topCond = null; - if (includeCategoryIds.size() > 0) { + if (!includeCategoryIds.isEmpty()) { for (String includeCategoryId: includeCategoryIds) { String categoryPrefix = "pcm" + this.index; String entityAlias = "PCM" + this.index; @@ -454,7 +454,7 @@ public class ProductSearch { incExcCondList.add(EntityCondition.makeCondition(categoryPrefix + "ProductCategoryId", EntityOperator.EQUALS, includeCategoryId)); } } - if (includeFeatureIds.size() > 0) { + if (!includeFeatureIds.isEmpty()) { for (String includeFeatureId: includeFeatureIds) { String featurePrefix = "pfa" + this.index; String entityAlias = "PFA" + this.index; @@ -472,7 +472,7 @@ public class ProductSearch { incExcCondList.add(EntityCondition.makeCondition(featurePrefix + "ProductFeatureId", EntityOperator.EQUALS, includeFeatureId)); } } - if (includeFeatureCategoryIds.size() > 0) { + if (!includeFeatureCategoryIds.isEmpty()) { for (String includeFeatureCategoryId: includeFeatureCategoryIds) { String featurePrefix = "pfa" + this.index; String entityAlias = "PFA" + this.index; @@ -496,7 +496,7 @@ public class ProductSearch { includeFeatureCategoryId)); } } - if (includeFeatureGroupIds.size() > 0) { + if (!includeFeatureGroupIds.isEmpty()) { for (String includeFeatureGroupId: includeFeatureGroupIds) { String featurePrefix = "pfa" + this.index; String entityAlias = "PFA" + this.index; @@ -527,7 +527,7 @@ public class ProductSearch { } } - if (excludeCategoryIds.size() > 0) { + if (!excludeCategoryIds.isEmpty()) { List<EntityCondition> idExcludeCondList = new LinkedList<>(); idExcludeCondList.add(EntityCondition.makeCondition(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN, this.nowTimestamp))); @@ -537,7 +537,7 @@ public class ProductSearch { EntityCondition.makeCondition(idExcludeCondList, EntityOperator.AND), true, delegator); incExcCondList.add(EntityCondition.makeCondition("mainProductId", EntityOperator.NOT_EQUAL, subSelCond)); } - if (excludeFeatureIds.size() > 0) { + if (!excludeFeatureIds.isEmpty()) { List<EntityCondition> idExcludeCondList = new LinkedList<>(); idExcludeCondList.add(EntityCondition.makeCondition(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN, this.nowTimestamp))); @@ -547,7 +547,7 @@ public class ProductSearch { EntityCondition.makeCondition(idExcludeCondList, EntityOperator.AND), true, delegator); incExcCondList.add(EntityCondition.makeCondition("mainProductId", EntityOperator.NOT_EQUAL, subSelCond)); } - if (excludeFeatureCategoryIds.size() > 0) { + if (!excludeFeatureCategoryIds.isEmpty()) { List<EntityCondition> idExcludeCondList = new LinkedList<>(); idExcludeCondList.add(EntityCondition.makeCondition(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN, this.nowTimestamp))); @@ -557,7 +557,7 @@ public class ProductSearch { EntityCondition.makeCondition(idExcludeCondList, EntityOperator.AND), true, delegator); incExcCondList.add(EntityCondition.makeCondition("mainProductId", EntityOperator.NOT_EQUAL, subSelCond)); } - if (excludeFeatureGroupIds.size() > 0) { + if (!excludeFeatureGroupIds.isEmpty()) { List<EntityCondition> idExcludeCondList = new LinkedList<>(); idExcludeCondList.add(EntityCondition.makeCondition(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN, this.nowTimestamp))); @@ -571,7 +571,7 @@ public class ProductSearch { incExcCondList.add(EntityCondition.makeCondition("mainProductId", EntityOperator.NOT_EQUAL, subSelCond)); } - if (alwaysIncludeCategoryIds.size() > 0) { + if (!alwaysIncludeCategoryIds.isEmpty()) { String categoryPrefix = "pcm" + this.index; String entityAlias = "PCM" + this.index; this.index++; @@ -587,7 +587,7 @@ public class ProductSearch { alwIncCondList.add(EntityCondition.makeCondition(categoryPrefix + "FromDate", EntityOperator.LESS_THAN, this.nowTimestamp)); alwIncCondList.add(EntityCondition.makeCondition(categoryPrefix + "ProductCategoryId", EntityOperator.IN, alwaysIncludeCategoryIds)); } - if (alwaysIncludeFeatureIds.size() > 0) { + if (!alwaysIncludeFeatureIds.isEmpty()) { String featurePrefix = "pfa" + this.index; String entityAlias = "PFA" + this.index; this.index++; @@ -603,7 +603,7 @@ public class ProductSearch { alwIncCondList.add(EntityCondition.makeCondition(featurePrefix + "FromDate", EntityOperator.LESS_THAN, this.nowTimestamp)); alwIncCondList.add(EntityCondition.makeCondition(featurePrefix + "ProductFeatureId", EntityOperator.IN, alwaysIncludeFeatureIds)); } - if (alwaysIncludeFeatureCategoryIds.size() > 0) { + if (!alwaysIncludeFeatureCategoryIds.isEmpty()) { for (String alwaysIncludeFeatureCategoryId: alwaysIncludeFeatureCategoryIds) { String featurePrefix = "pfa" + this.index; String entityAlias = "PFA" + this.index; @@ -626,7 +626,7 @@ public class ProductSearch { alwaysIncludeFeatureCategoryId)); } } - if (alwaysIncludeFeatureGroupIds.size() > 0) { + if (!alwaysIncludeFeatureGroupIds.isEmpty()) { for (String alwaysIncludeFeatureGroupId: alwaysIncludeFeatureGroupIds) { String featurePrefix = "pfa" + this.index; String entityAlias = "PFA" + this.index; @@ -657,7 +657,7 @@ public class ProductSearch { } // handle includeFeatureIdOrSetAndList and alwaysIncludeFeatureIdOrSetAndList - if (includeFeatureIdOrSetAndList.size() > 0) { + if (!includeFeatureIdOrSetAndList.isEmpty()) { for (Set<String> includeFeatureIdOrSet: includeFeatureIdOrSetAndList) { String featurePrefix = "pfa" + this.index; String entityAlias = "PFA" + this.index; @@ -675,7 +675,7 @@ public class ProductSearch { incExcCondList.add(EntityCondition.makeCondition(featurePrefix + "ProductFeatureId", EntityOperator.IN, includeFeatureIdOrSet)); } } - if (alwaysIncludeFeatureIdOrSetAndList.size() > 0) { + if (!alwaysIncludeFeatureIdOrSetAndList.isEmpty()) { for (Set<String> alwaysIncludeFeatureIdOrSet: alwaysIncludeFeatureIdOrSetAndList) { String featurePrefix = "pfa" + this.index; String entityAlias = "PFA" + this.index; @@ -693,7 +693,7 @@ public class ProductSearch { } // handle includeCategoryIdOrSetAndList and alwaysIncludeCategoryIdOrSetAndList - if (includeCategoryIdOrSetAndList.size() > 0) { + if (!includeCategoryIdOrSetAndList.isEmpty()) { for (Set<String> includeCategoryIdOrSet: includeCategoryIdOrSetAndList) { String categoryPrefix = "pcm" + this.index; String entityAlias = "PCM" + this.index; @@ -709,7 +709,7 @@ public class ProductSearch { incExcCondList.add(EntityCondition.makeCondition(categoryPrefix + "ProductCategoryId", EntityOperator.IN, includeCategoryIdOrSet)); } } - if (alwaysIncludeCategoryIdOrSetAndList.size() > 0) { + if (!alwaysIncludeCategoryIdOrSetAndList.isEmpty()) { for (Set<String> alwaysIncludeCategoryIdOrSet: alwaysIncludeCategoryIdOrSetAndList) { String categoryPrefix = "pcm" + this.index; String entityAlias = "PCM" + this.index; @@ -726,10 +726,10 @@ public class ProductSearch { } } - if (incExcCondList.size() > 0) { + if (!incExcCondList.isEmpty()) { incExcCond = EntityCondition.makeCondition(incExcCondList, EntityOperator.AND); } - if (alwIncCondList.size() > 0) { + if (!alwIncCondList.isEmpty()) { alwIncCond = EntityCondition.makeCondition(alwIncCondList, EntityOperator.AND); } @@ -2601,11 +2601,11 @@ public class ProductSearch { public void setSortOrder(ProductSearchContext productSearchContext) { if (productSearchContext.includedKeywordSearch) { // we have to check this in order to be sure that there is a totalRelevancy to sort by... - if (productSearchContext.keywordFixedOrSetAndList.size() > 0 || productSearchContext.andKeywordFixedSet.size() > 0) { + if (!productSearchContext.keywordFixedOrSetAndList.isEmpty() || !productSearchContext.andKeywordFixedSet.isEmpty()) { productSearchContext.orderByList.add("-totalRelevancy"); productSearchContext.fieldsToSelect.add("totalRelevancy"); } - if (productSearchContext.keywordFixedOrSetAndList.size() > 0) { + if (!productSearchContext.keywordFixedOrSetAndList.isEmpty()) { productSearchContext.productIdGroupBy = true; } } diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearchSession.java b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearchSession.java index 5ae9c19..64ab234 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearchSession.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearchSession.java @@ -452,7 +452,7 @@ public class ProductSearchSession { } } - if (keywords.size() > 0) { + if (!keywords.isEmpty()) { List<GenericValue> productStoreKeywordOvrdList = null; try { productStoreKeywordOvrdList = EntityQuery.use(delegator).from("ProductStoreKeywordOvrd").where("productStoreId", productStoreId) @@ -759,7 +759,7 @@ public class ProductSearchSession { // if features were selected add a constraint for each Map<String, String> featureIdByType = ParametricSearch.makeFeatureIdByTypeMap(parameters); - if (featureIdByType.size() > 0) { + if (!featureIdByType.isEmpty()) { constraintsChanged = true; searchAddFeatureIdConstraints(featureIdByType.values(), null, request); } diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductServices.java b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductServices.java index 84b9f90..ff08f10 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductServices.java @@ -159,7 +159,7 @@ public class ProductServices { return ServiceUtil.returnError(errMsg); } - if (featureSet.size() == 0) { + if (featureSet.isEmpty()) { errMsg = UtilProperties.getMessage(RES_ERROR, "productservices.problem_reading_product_features", locale); // ToDo DO 2004-02-23 Where should the errMsg go? Debug.logWarning(errMsg + " for product " + productId, MODULE); @@ -318,7 +318,7 @@ public class ProductServices { return ServiceUtil.returnError(e.getMessage()); } - if (outOfStockItems.size() > 0) { + if (!outOfStockItems.isEmpty()) { result.put("unavailableVariants", outOfStockItems); } result.put("variantSample", sample); @@ -389,7 +389,7 @@ public class ProductServices { if (product.get("isVariant") != null && "Y".equalsIgnoreCase(product.getString("isVariant"))) { List<GenericValue> c = product.getRelated("AssocProductAssoc", UtilMisc.toMap("productAssocTypeId", "PRODUCT_VARIANT"), null, true); c = EntityUtil.filterByDate(c); - if (c.size() > 0) { + if (!c.isEmpty()) { GenericValue asV = c.iterator().next(); mainProduct = asV.getRelatedOne("MainProduct", true); } @@ -602,7 +602,7 @@ public class ProductServices { } // no groups; no tree - if (group.size() == 0) { + if (group.isEmpty()) { return group; } @@ -1121,7 +1121,7 @@ public class ProductServices { GenericValue userLogin = (GenericValue) context.get("userLogin"); String productId = (String) context.get("productId"); - if (UtilValidate.isNotEmpty(imageUrl) && imageUrl.length() > 0) { + if (UtilValidate.isNotEmpty(imageUrl) && !imageUrl.isEmpty()) { String contentId = (String) context.get("contentId"); Map<String, Object> dataResourceCtx = new HashMap<>(); @@ -1361,7 +1361,7 @@ public class ProductServices { String imageUrl = imageUrlPrefix + "/" + filePathPrefix + filenameToUse; - if (UtilValidate.isNotEmpty(imageUrl) && imageUrl.length() > 0) { + if (UtilValidate.isNotEmpty(imageUrl) && !imageUrl.isEmpty()) { Map<String, Object> dataResourceCtx = new HashMap<>(); dataResourceCtx.put("objectInfo", imageUrl); dataResourceCtx.put("dataResourceName", context.get("_uploadedFile_fileName")); diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductUtilServices.java b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductUtilServices.java index ea42582..cf3d12e 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductUtilServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductUtilServices.java @@ -90,7 +90,7 @@ public final class ProductUtilServices { .where("productId", virtualProductId, "productIdTo", productOne.get("productId"), "productAssocTypeId", "PRODUCT_VARIANT") .filterByDate() .queryList(); - if (passocList.size() > 0) { + if (!passocList.isEmpty()) { for (GenericValue passoc : passocList) { passoc.set("thruDate", nowTimestamp); passoc.store(); @@ -111,7 +111,7 @@ public final class ProductUtilServices { int numSoFar = 0; while ((product = eli.next()) != null) { List<GenericValue> passocList = EntityQuery.use(delegator).from("ProductAssoc").where("productId", product.get("productId"), "productAssocTypeId", "PRODUCT_VARIANT").filterByDate().queryList(); - if (passocList.size() == 0) { + if (passocList.isEmpty()) { product.set("salesDiscontinuationDate", nowTimestamp); delegator.store(product); @@ -155,7 +155,7 @@ public final class ProductUtilServices { while ((product = eli.next()) != null) { String productId = product.getString("productId"); List<GenericValue> productCategoryMemberList = EntityQuery.use(delegator).from("ProductCategoryMember").where("productId", productId).queryList(); - if (productCategoryMemberList.size() > 0) { + if (!productCategoryMemberList.isEmpty()) { for (GenericValue productCategoryMember : productCategoryMemberList) { // coded this way rather than a removeByAnd so it can be easily changed... productCategoryMember.remove(); @@ -360,7 +360,7 @@ public final class ProductUtilServices { return ServiceUtil.returnError(errMsg); } - if (paList.size() == 0) { + if (paList.isEmpty()) { Map<String, String> messageMap = UtilMisc.toMap("productId", productId); errMsg = UtilProperties.getMessage(RES_ERROR, "productutilservices.did_not_find_any_valid_variants_for_virtual_ID", messageMap, locale); Debug.logInfo(errMsg, MODULE); @@ -460,7 +460,7 @@ public final class ProductUtilServices { // can't just set to null, need to remove the value so it isn't a constraint in the query findValue.remove("fromDate"); List<GenericValue> existingValueList = EntityQuery.use(delegator).from(relatedEntityName).where(findValue).filterByDate(nowTimestamp).queryList(); - if (existingValueList.size() > 0) { + if (!existingValueList.isEmpty()) { if (test) { Debug.logInfo("Found " + existingValueList.size() + " existing values for related entity name: " + relatedEntityName + ", not copying, findValue is: " + findValue, MODULE); } @@ -520,7 +520,7 @@ public final class ProductUtilServices { if ("Y".equals(product.getString("isVirtual"))) { // find the first variant, use it's ID for the names... List<GenericValue> productAssocList = EntityQuery.use(delegator).from("ProductAssoc").where("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT").filterByDate().queryList(); - if (productAssocList.size() > 0) { + if (!productAssocList.isEmpty()) { GenericValue productAssoc = EntityUtil.getFirst(productAssocList); smallMap.put("productId", productAssoc.getString("productIdTo")); mediumMap.put("productId", productAssoc.getString("productIdTo")); @@ -609,7 +609,7 @@ public final class ProductUtilServices { String includeProp = EntityUtilProperties.getPropertyValue("prodsearch", "attach.feature.type.include", delegator); if (UtilValidate.isNotEmpty(includeProp)) { List<String> typeList = StringUtil.split(includeProp, ","); - if (typeList.size() > 0) { + if (!typeList.isEmpty()) { productFeatureTypeIdsToInclude = new LinkedHashSet<>(typeList); } } diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/promo/PromoServices.java b/applications/product/src/main/java/org/apache/ofbiz/product/promo/PromoServices.java index 77ac894..cdacb0b 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/promo/PromoServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/promo/PromoServices.java @@ -189,7 +189,7 @@ public class PromoServices { try { while ((line = reader.readLine()) != null) { // check to see if we should ignore this line - if (line.length() > 0 && !line.startsWith("#")) { + if (!line.isEmpty() && !line.startsWith("#")) { if (line.length() <= 20) { // valid promo code Map<String, Object> inContext = new HashMap<>(); @@ -218,7 +218,7 @@ public class PromoServices { } // return errors or success - if (errors.size() > 0) { + if (!errors.isEmpty()) { return ServiceUtil.returnError(errors); } else if (lines == 0) { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, @@ -251,7 +251,7 @@ public class PromoServices { // read the uploaded file and process each line try { while ((line = reader.readLine()) != null) { - if (line.length() > 0 && !line.startsWith("#")) { + if (!line.isEmpty() && !line.startsWith("#")) { if (UtilValidate.isEmail(line)) { // valid email address GenericValue contactMech; @@ -306,7 +306,7 @@ public class PromoServices { } // return errors or success - if (errors.size() > 0) { + if (!errors.isEmpty()) { return ServiceUtil.returnError(errors); } else if (lines == 0) { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/spreadsheetimport/ImportProductServices.java b/applications/product/src/main/java/org/apache/ofbiz/product/spreadsheetimport/ImportProductServices.java index b725891..29cef3b 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/spreadsheetimport/ImportProductServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/spreadsheetimport/ImportProductServices.java @@ -167,7 +167,7 @@ public class ImportProductServices { } } int uploadedProducts = products.size() + 1; - if (products.size() > 0) { + if (!products.isEmpty()) { Debug.logInfo("Uploaded " + uploadedProducts + " products from file " + item.getName(), MODULE); } } diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/subscription/SubscriptionServices.java b/applications/product/src/main/java/org/apache/ofbiz/product/subscription/SubscriptionServices.java index c46a71d..6a495b2 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/subscription/SubscriptionServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/subscription/SubscriptionServices.java @@ -82,7 +82,7 @@ public class SubscriptionServices { List<GenericValue> subscriptionList = EntityQuery.use(delegator).from("Subscription").where(subscriptionFindMap).queryList(); // DEJ20070718 DON'T filter by date, we want to consider all subscriptions: List listFiltered = EntityUtil.filterByDate(subscriptionList, true); List<GenericValue> listOrdered = EntityUtil.orderBy(subscriptionList, UtilMisc.toList("-fromDate")); - if (listOrdered.size() > 0) { + if (!listOrdered.isEmpty()) { lastSubscription = listOrdered.get(0); } } catch (GenericEntityException e) { @@ -203,7 +203,7 @@ public class SubscriptionServices { .filterByDate(orderCreatedDate, "fromDate", "thruDate", "purchaseFromDate", "purchaseThruDate") .queryList(); - if (productSubscriptionResourceList.size() == 0) { + if (productSubscriptionResourceList.isEmpty()) { Debug.logError("No ProductSubscriptionResource found for productId: " + productId, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ProductSubscriptionResourceNotFound", @@ -256,7 +256,7 @@ public class SubscriptionServices { GenericValue orderHeader = null; try { List<GenericValue> orderRoleList = EntityQuery.use(delegator).from("OrderRole").where("orderId", orderId, "roleTypeId", "END_USER_CUSTOMER").queryList(); - if (orderRoleList.size() > 0) { + if (!orderRoleList.isEmpty()) { GenericValue orderRole = orderRoleList.get(0); String partyId = (String) orderRole.get("partyId"); subContext.put("partyId", partyId); @@ -281,7 +281,7 @@ public class SubscriptionServices { continue; } List<GenericValue> productSubscriptionResourceListFiltered = EntityQuery.use(delegator).from("ProductSubscriptionResource").where("productId", productId).cache(true).filterByDate().queryList(); - if (productSubscriptionResourceListFiltered.size() > 0) { + if (!productSubscriptionResourceListFiltered.isEmpty()) { subContext.put("subscriptionTypeId", "PRODUCT_SUBSCR"); subContext.put("productId", productId); subContext.put("orderId", orderId); diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/supplier/SupplierProductServices.java b/applications/product/src/main/java/org/apache/ofbiz/product/supplier/SupplierProductServices.java index 249e515..c5270e7 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/supplier/SupplierProductServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/supplier/SupplierProductServices.java @@ -75,7 +75,7 @@ public class SupplierProductServices { List<GenericValue> supplierProducts = product.getRelated("SupplierProduct", null, null, true); // if there were no related SupplierProduct entities and the item is a variant, then get the SupplierProducts of the virtual parent product - if (supplierProducts.size() == 0 && product.getString("isVariant") != null && "Y".equals(product.getString("isVariant"))) { + if (supplierProducts.isEmpty() && product.getString("isVariant") != null && "Y".equals(product.getString("isVariant"))) { String virtualProductId = ProductWorker.getVariantVirtualId(product); GenericValue virtualProduct = EntityQuery.use(delegator).from("Product").where("productId", virtualProductId).cache().queryOne(); if (virtualProduct != null) { @@ -141,7 +141,7 @@ public class SupplierProductServices { UtilMisc.toMap("partyId", partyId)); GenericValue supplierFeature = null; - if ((supplierFeatures != null) && (supplierFeatures.size() > 0)) { + if ((supplierFeatures != null) && (!supplierFeatures.isEmpty())) { supplierFeature = supplierFeatures.get(0); if (supplierFeature.get("description") != null) { nextFeature.put("description", supplierFeature.get("description")); diff --git a/applications/product/src/main/java/org/apache/ofbiz/shipment/packing/PackingSession.java b/applications/product/src/main/java/org/apache/ofbiz/shipment/packing/PackingSession.java index c7eb7eb..cf23f76 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/shipment/packing/PackingSession.java +++ b/applications/product/src/main/java/org/apache/ofbiz/shipment/packing/PackingSession.java @@ -938,7 +938,7 @@ public class PackingSession implements java.io.Serializable { */ public String complete(boolean force) throws GeneralException { // check to see if there is anything to process - if (this.getLines().size() == 0) { + if (this.getLines().isEmpty()) { return "EMPTY"; } @@ -986,7 +986,7 @@ public class PackingSession implements java.io.Serializable { } } - if (errors.size() > 0) { + if (!errors.isEmpty()) { if (!ignore) { throw new GeneralException("Attempt to pack order failed.", errors); } else { @@ -1014,7 +1014,7 @@ public class PackingSession implements java.io.Serializable { * @param eventCode the event code */ protected void runEvents(int eventCode) { - if (this.packEvents.size() > 0) { + if (!this.packEvents.isEmpty()) { for (PackingEvent event: this.packEvents) { event.runEvent(this, eventCode); } diff --git a/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentServices.java b/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentServices.java index 718982e..fa3456f 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentServices.java @@ -818,7 +818,7 @@ public class ShipmentServices { try { List<GenericValue> shipmentReceipts = EntityQuery.use(delegator).from("ShipmentReceipt").where("shipmentId", shipmentId).queryList(); - if (shipmentReceipts.size() == 0) return ServiceUtil.returnSuccess(); + if (shipmentReceipts.isEmpty()) return ServiceUtil.returnSuccess(); // If there are shipment receipts, the shipment must have been shipped, so set the shipment status to PURCH_SHIP_SHIPPED if it's only PURCH_SHIP_CREATED GenericValue shipment = EntityQuery.use(delegator).from("Shipment").where("shipmentId", shipmentId).queryOne(); @@ -830,7 +830,7 @@ public class ShipmentServices { } List<GenericValue> shipmentAndItems = EntityQuery.use(delegator).from("ShipmentAndItem").where("shipmentId", shipmentId, "statusId", "PURCH_SHIP_SHIPPED").queryList(); - if (shipmentAndItems.size() == 0) { + if (shipmentAndItems.isEmpty()) { return ServiceUtil.returnSuccess(); } diff --git a/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentWorker.java b/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentWorker.java index 8b534e8..d89d00c 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentWorker.java +++ b/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentWorker.java @@ -133,7 +133,7 @@ public final class ShipmentWorker { packages.add(newPackage); } else if (totalWeight.compareTo(BigDecimal.ZERO) > 0) { // create the first package - if (packages.size() == 0) { + if (packages.isEmpty()) { packages.add(new HashMap<>()); } diff --git a/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/dhl/DhlServices.java b/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/dhl/DhlServices.java index 1f465f8..9bb69a3 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/dhl/DhlServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/dhl/DhlServices.java @@ -192,7 +192,7 @@ public class DhlServices { String password = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "accessPassword", RESOURCE, "shipment.dhl.access.password"); String shippingKey = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "accessShippingKey", RESOURCE, "shipment.dhl.access.shippingKey"); String accountNbr = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "accessAccountNbr", RESOURCE, "shipment.dhl.access.accountNbr"); - if ((shippingKey.length() == 0) || (accountNbr.length() == 0)) { + if ((shippingKey.isEmpty()) || (accountNbr.isEmpty())) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "FacilityShipmentDhlGatewayNotAvailable", locale)); } @@ -236,7 +236,7 @@ public class DhlServices { // create AccessRequest XML doc using FreeMarker template String templateName = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "rateEstimateTemplate", RESOURCE, "shipment.dhl.template.rate.estimate"); - if (templateName.trim().length() == 0) { + if (templateName.trim().isEmpty()) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "FacilityShipmentDhlShipmentTemplateLocationNotFound", locale)); } @@ -678,7 +678,7 @@ public class DhlServices { String password = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "accessPassword", RESOURCE, "shipment.dhl.access.password"); String shippingKey = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "accessShippingKey", RESOURCE, "shipment.dhl.access.shippingKey"); String accountNbr = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "accessAccountNbr", RESOURCE, "shipment.dhl.access.accountNbr"); - if ((shippingKey.length() == 0) || (accountNbr.length() == 0)) { + if ((shippingKey.isEmpty()) || (accountNbr.isEmpty())) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "FacilityShipmentDhlGatewayNotAvailable", locale)); } @@ -697,7 +697,7 @@ public class DhlServices { // create AccessRequest XML doc using FreeMarker template String templateName = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "rateEstimateTemplate", RESOURCE, "shipment.dhl.template.rate.estimate"); - if ((templateName.trim().length() == 0)) { + if ((templateName.trim().isEmpty())) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "FacilityShipmentDhlRateEstimateTemplateNotConfigured", locale)); } diff --git a/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/ups/UpsServices.java b/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/ups/UpsServices.java index 2105828..a828d8e 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/ups/UpsServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/ups/UpsServices.java @@ -238,7 +238,7 @@ public class UpsServices { odBuf.append(orderId); } ordersDescription = odBuf.toString(); - } else if (orderIdSet.size() > 0) { + } else if (!orderIdSet.isEmpty()) { ordersDescription = UtilProperties.getMessage(RES_ORDER, "OrderOrder", locale) + " " + orderIdSet.iterator().next(); } @@ -530,7 +530,7 @@ public class UpsServices { List<GenericValue> carrierShipmentBoxTypes = shipmentPackage.getRelated("CarrierShipmentBoxType", UtilMisc.toMap("partyId", "UPS"), null, false); GenericValue carrierShipmentBoxType = null; - if (carrierShipmentBoxTypes.size() > 0) { + if (!carrierShipmentBoxTypes.isEmpty()) { carrierShipmentBoxType = carrierShipmentBoxTypes.get(0); } @@ -848,7 +848,7 @@ public class UpsServices { StringBuilder successString = new StringBuilder(UtilProperties.getMessage(RES_ERROR, "FacilityShipmentUpsShipmentConfirmSucceeded", locale)); - if (errorList.size() > 0) { + if (!errorList.isEmpty()) { // this shouldn't happen much, but handle it anyway successString.append(UtilProperties.getMessage(RES_ERROR, "FacilityShipmentUpsShipmentConfirmError", locale)); Iterator<Object> errorListIter = errorList.iterator(); @@ -1255,7 +1255,7 @@ public class UpsServices { // -=-=-=- Okay, now done with that, just return any extra info... StringBuilder successString = new StringBuilder(UtilProperties.getMessage(RES_ERROR, "FacilityShipmentUpsShipmentAcceptSucceeded", locale)); - if (errorList.size() > 0) { + if (!errorList.isEmpty()) { // this shouldn't happen much, but handle it anyway successString.append(UtilProperties.getMessage(RES_ERROR, "FacilityShipmentUpsShipmentAcceptError", locale)); @@ -1449,7 +1449,7 @@ public class UpsServices { StringBuilder successString = new StringBuilder(UtilProperties.getMessage(RES_ERROR, "FacilityShipmentUpsShipmentVoidSucceeded", UtilMisc.toMap("statusTypeCode", statusTypeCode, "statusTypeDescription", statusTypeDescription, "statusCodeCode", statusCodeCode, "statusCodeDescription", statusCodeDescription), locale)); - if (errorList.size() > 0) { + if (!errorList.isEmpty()) { // this shouldn't happen much, but handle it anyway successString.append(UtilProperties.getMessage(RES_ERROR, "FacilityShipmentUpsShipmentVoidError", locale)); Iterator<Object> errorListIter = errorList.iterator(); @@ -1668,7 +1668,7 @@ public class UpsServices { // -=-=-=- Okay, now done with that, just return any extra info... StringBuilder successString = new StringBuilder(UtilProperties.getMessage(RES_ERROR, "FacilityShipmentUpsShipmentTrackSucceeded", locale)); - if (errorList.size() > 0) { + if (!errorList.isEmpty()) { // this shouldn't happen much, but handle it anyway successString.append(UtilProperties.getMessage(RES_ERROR, "FacilityShipmentUpsShipmentTrackError", locale)); Iterator<Object> errorListIter = errorList.iterator(); @@ -2978,7 +2978,7 @@ public class UpsServices { List<GenericValue> carrierShipmentBoxTypes = shipmentPackage.getRelated("CarrierShipmentBoxType", UtilMisc.toMap("partyId", "UPS"), null, false); GenericValue carrierShipmentBoxType = null; - if (carrierShipmentBoxTypes.size() > 0) { + if (!carrierShipmentBoxTypes.isEmpty()) { carrierShipmentBoxType = carrierShipmentBoxTypes.get(0); } diff --git a/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/usps/UspsServices.java b/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/usps/UspsServices.java index 1b5c888..8ff24a1 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/usps/UspsServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/usps/UspsServices.java @@ -1093,7 +1093,7 @@ public class UspsServices { List<GenericValue> carrierShipmentBoxTypes = null; carrierShipmentBoxTypes = shipmentPackage.getRelated("CarrierShipmentBoxType", UtilMisc.toMap("partyId", "USPS"), null, false); - if (carrierShipmentBoxTypes.size() > 0) { + if (!carrierShipmentBoxTypes.isEmpty()) { carrierShipmentBoxType = carrierShipmentBoxTypes.get(0); } diff --git a/applications/product/src/main/java/org/apache/ofbiz/shipment/verify/VerifyPickSession.java b/applications/product/src/main/java/org/apache/ofbiz/shipment/verify/VerifyPickSession.java index 38b767c..9accc43 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/shipment/verify/VerifyPickSession.java +++ b/applications/product/src/main/java/org/apache/ofbiz/shipment/verify/VerifyPickSession.java @@ -379,7 +379,7 @@ public class VerifyPickSession implements Serializable { } } - if (errorList.size() > 0) { + if (!errorList.isEmpty()) { throw new GeneralException(UtilProperties.getMessage("OrderErrorUiLabels", "OrderErrorAttemptToVerifyOrderFailed", UtilMisc.toMap("orderId", orderId), locale), errorList); } } diff --git a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalConverter.java b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalConverter.java index b00646f..ebaaee4 100644 --- a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalConverter.java +++ b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalConverter.java @@ -819,7 +819,7 @@ public class ICalConverter { List<GenericValue> assignments = null; try { assignments = EntityQuery.use(delegator).from("WorkEffortPartyAssignment").where(serviceMap).filterByDate().queryList(); - if (assignments.size() == 0) { + if (assignments.isEmpty()) { serviceMap.put("statusId", "PRTYASGN_OFFERED"); serviceMap.put("fromDate", new Timestamp(System.currentTimeMillis())); invokeService("assignPartyToWorkEffort", serviceMap, context); @@ -918,7 +918,7 @@ public class ICalConverter { replaceProperty(componentProps, toDuration(workEffort.getDouble("estimatedMilliSeconds"))); } List<GenericValue> relatedParties = EntityQuery.use(delegator).from("WorkEffortPartyAssignView").where("workEffortId", workEffortId).cache(true).filterByDate().queryList(); - if (relatedParties.size() > 0) { + if (!relatedParties.isEmpty()) { loadRelatedParties(relatedParties, componentProps, context); } if (newComponent) { diff --git a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalRecurConverter.java b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalRecurConverter.java index 47e4e58..dab55a8 100644 --- a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalRecurConverter.java +++ b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalRecurConverter.java @@ -75,7 +75,7 @@ public class ICalRecurConverter implements TemporalExpressionVisitor { dateStart = converter.dateStart; eventProps.add(dateStart); } - if (dateStart != null && converter.exRuleList.size() > 0) { + if (dateStart != null && !converter.exRuleList.isEmpty()) { // iCalendar quirk - if exclusions exist, then the start date must be excluded also ExDate exdate = new ExDate(); exdate.getDates().add(dateStart.getDate()); @@ -118,13 +118,13 @@ public class ICalRecurConverter implements TemporalExpressionVisitor { freqCount = recur.getInterval(); } } - if (freq == null && monthList.size() > 0) { + if (freq == null && !monthList.isEmpty()) { freq = Recur.MONTHLY; - } else if (freq == null && (monthDayList.size() > 0 || weekDayList.size() > 0)) { + } else if (freq == null && (!monthDayList.isEmpty() || !weekDayList.isEmpty())) { freq = Recur.DAILY; - } else if (freq == null && hourList.size() > 0) { + } else if (freq == null && !hourList.isEmpty()) { freq = Recur.HOURLY; - } else if (freq == null && minuteList.size() > 0) { + } else if (freq == null && !minuteList.isEmpty()) { freq = Recur.MINUTELY; } if (freq == null) { @@ -181,10 +181,10 @@ public class ICalRecurConverter implements TemporalExpressionVisitor { childExpr.accept(this); } this.state = this.stateStack.pop(); - if (newState.inclRecurList.size() > 0) { + if (!newState.inclRecurList.isEmpty()) { this.incRuleList.add(new RRule(this.consolidateRecurs(newState.inclRecurList))); } - if (newState.exRecurList.size() > 0) { + if (!newState.exRecurList.isEmpty()) { this.exRuleList.add(new ExRule(this.consolidateRecurs(newState.exRecurList))); } } diff --git a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalWorker.java b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalWorker.java index aa87153..b4304a2 100644 --- a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalWorker.java +++ b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalWorker.java @@ -190,11 +190,11 @@ public final class ICalWorker { } Element responseElement = helper.createResponseElement(); responseElement.appendChild(helper.createHrefElement("/" + workEffortId + "/")); - if (supportedProps.size() > 0) { + if (!supportedProps.isEmpty()) { Element propElement = helper.createPropElement(supportedProps); responseElement.appendChild(helper.createPropStatElement(propElement, ResponseHelper.STATUS_200)); } - if (unSupportedProps.size() > 0) { + if (!unSupportedProps.isEmpty()) { Element propElement = helper.createPropElement(unSupportedProps); responseElement.appendChild(helper.createPropStatElement(propElement, ResponseHelper.STATUS_404)); } diff --git a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortKeywordIndex.java b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortKeywordIndex.java index ccff525..c2436e0 100644 --- a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortKeywordIndex.java +++ b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortKeywordIndex.java @@ -119,7 +119,7 @@ public class WorkEffortKeywordIndex { toBeStored.add(workEffortKeyword); } } - if (toBeStored.size() > 0) { + if (!toBeStored.isEmpty()) { if (Debug.verboseOn()) { Debug.logVerbose("WorkEffortKeywordIndex indexKeywords Storing " + toBeStored.size() + " keywords for workEffortId " + workEffort.getString("workEffortId"), MODULE); } diff --git a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearch.java b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearch.java index 08b0c60..88ab52e 100644 --- a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearch.java +++ b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearch.java @@ -230,7 +230,7 @@ public class WorkEffortSearch { } public void finishKeywordConstraints() { - if (orKeywordFixedSet.size() == 0 && andKeywordFixedSet.size() == 0 && keywordFixedOrSetAndList.size() == 0) { + if (orKeywordFixedSet.isEmpty() && andKeywordFixedSet.isEmpty() && keywordFixedOrSetAndList.isEmpty()) { return; } @@ -238,7 +238,7 @@ public class WorkEffortSearch { this.includedKeywordSearch = true; // if there is anything in the orKeywordFixedSet add it to the keywordFixedOrSetAndList - if (orKeywordFixedSet.size() > 0) { + if (!orKeywordFixedSet.isEmpty()) { // put in keywordFixedOrSetAndList to process with other or lists where at least one is required keywordFixedOrSetAndList.add(orKeywordFixedSet); } @@ -247,7 +247,7 @@ public class WorkEffortSearch { Iterator<Set<String>> keywordFixedOrSetAndTestIter = keywordFixedOrSetAndList.iterator(); while (keywordFixedOrSetAndTestIter.hasNext()) { Set<String> keywordFixedOrSet = keywordFixedOrSetAndTestIter.next(); - if (keywordFixedOrSet.size() == 0) { + if (keywordFixedOrSet.isEmpty()) { keywordFixedOrSetAndTestIter.remove(); } else if (keywordFixedOrSet.size() == 1) { // treat it as just another and @@ -256,13 +256,13 @@ public class WorkEffortSearch { } } - boolean doingBothAndOr = (keywordFixedOrSetAndList.size() > 1) || (keywordFixedOrSetAndList.size() > 0 && andKeywordFixedSet.size() > 0); + boolean doingBothAndOr = (keywordFixedOrSetAndList.size() > 1) || (!keywordFixedOrSetAndList.isEmpty() && !andKeywordFixedSet.isEmpty()); Debug.logInfo("Finished initial setup of keywords, doingBothAndOr=" + doingBothAndOr + ", andKeywordFixedSet=" + andKeywordFixedSet + "\n keywordFixedOrSetAndList=" + keywordFixedOrSetAndList, MODULE); ComplexAlias relevancyComplexAlias = new ComplexAlias("+"); - if (andKeywordFixedSet.size() > 0) { + if (!andKeywordFixedSet.isEmpty()) { // add up the relevancyWeight fields from all keyword member entities for a total to sort by for (String keyword: andKeywordFixedSet) { @@ -287,7 +287,7 @@ public class WorkEffortSearch { dynamicViewEntity.addAlias(null, "totalRelevancy", null, null, null, null, null, relevancyComplexAlias); } } - if (keywordFixedOrSetAndList.size() > 0) { + if (!keywordFixedOrSetAndList.isEmpty()) { for (Set<String> keywordFixedOrSet: keywordFixedOrSetAndList) { // make index based values and increment String entityAlias = "PK" + index; diff --git a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortServices.java b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortServices.java index 876c9bc..13b47b0 100644 --- a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortServices.java +++ b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortServices.java @@ -433,7 +433,7 @@ public class WorkEffortServices { EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, "PROD_ORDER_TASK")), EntityJoinOperator.OR)); } EntityCondition typesCondition = null; - if (typesList.size() == 0) { + if (typesList.isEmpty()) { return entityExprList; } else if (typesList.size() == 1) { typesCondition = typesList.get(0); diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/conversion/DateTimeConverters.java b/framework/base/src/main/java/org/apache/ofbiz/base/conversion/DateTimeConverters.java index 90e566c..a8bf63e 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/conversion/DateTimeConverters.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/conversion/DateTimeConverters.java @@ -515,7 +515,7 @@ public class DateTimeConverters implements ConverterLoader { @Override public Calendar convert(String obj, Locale locale, TimeZone timeZone, String formatString) throws ConversionException { String trimStr = obj.trim(); - if (trimStr.length() == 0) { + if (trimStr.isEmpty()) { return null; } DateFormat df = null; @@ -541,7 +541,7 @@ public class DateTimeConverters implements ConverterLoader { @Override public java.util.Date convert(String obj, Locale locale, TimeZone timeZone, String formatString) throws ConversionException { String trimStr = obj.trim(); - if (trimStr.length() == 0) { + if (trimStr.isEmpty()) { return null; } DateFormat df = null; @@ -603,7 +603,7 @@ public class DateTimeConverters implements ConverterLoader { @Override public java.sql.Date convert(String obj, Locale locale, TimeZone timeZone, String formatString) throws ConversionException { String trimStr = obj.trim(); - if (trimStr.length() == 0) { + if (trimStr.isEmpty()) { return null; } DateFormat df = null; @@ -637,7 +637,7 @@ public class DateTimeConverters implements ConverterLoader { @Override public java.sql.Time convert(String obj, Locale locale, TimeZone timeZone, String formatString) throws ConversionException { String trimStr = obj.trim(); - if (trimStr.length() == 0) { + if (trimStr.isEmpty()) { return null; } DateFormat df = null; @@ -667,18 +667,18 @@ public class DateTimeConverters implements ConverterLoader { @Override public java.sql.Timestamp convert(String obj, Locale locale, TimeZone timeZone, String formatString) throws ConversionException { String str = obj.trim(); - if (str.length() == 0) { + if (str.isEmpty()) { return null; } DateFormat df = null; if (UtilValidate.isEmpty(formatString)) { // These hacks are a bad idea, but they are included // for backward compatibility. - if (str.length() > 0 && !str.contains(":")) { + if (!str.isEmpty() && !str.contains(":")) { str = str + " 00:00:00.00"; } // hack to mimic Timestamp.valueOf() method - if (str.length() > 0 && !str.contains(".")) { + if (!str.isEmpty() && !str.contains(".")) { str = str + ".0"; } else { // DateFormat has a funny way of parsing milliseconds: diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/conversion/NumberConverters.java b/framework/base/src/main/java/org/apache/ofbiz/base/conversion/NumberConverters.java index 2125b0c..78384d6 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/conversion/NumberConverters.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/conversion/NumberConverters.java @@ -51,7 +51,7 @@ public class NumberConverters implements ConverterLoader { @Override public N convert(String obj, Locale locale, TimeZone timeZone) throws ConversionException { String trimStr = StringUtil.removeSpaces(obj); - if (trimStr.length() == 0) { + if (trimStr.isEmpty()) { return null; } return convert(fromString(trimStr, locale)); diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/test/GenericTestCaseBase.java b/framework/base/src/main/java/org/apache/ofbiz/base/test/GenericTestCaseBase.java index 5aeae7d..02ae8c7 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/test/GenericTestCaseBase.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/test/GenericTestCaseBase.java @@ -293,7 +293,7 @@ OUTER: while (wantedIt.hasNext() && gotIt.hasNext()) { assertEquals(label + ":iterate", wantedIt.next(), gotIt.next()); } - while (wantedExtra.size() > 0) { + while (!wantedExtra.isEmpty()) { assertTrue(label + ":wanted-extra(" + wantedExtra + ")-hasNext", wantedIt.hasNext()); assertEquals(label + ":wanted-extra(" + wantedExtra + ")", wantedExtra.remove(0), wantedIt.next()); if (removeWanted) { @@ -301,7 +301,7 @@ OUTER: } } assertFalse(label + ":wanted-done", wantedIt.hasNext()); - while (gotExtra.size() > 0) { + while (!gotExtra.isEmpty()) { assertTrue(label + ":got-extra(" + gotExtra + ")-hasNext", gotIt.hasNext()); assertEquals(label + ":got-extra(" + gotExtra + ")", gotExtra.remove(0), gotIt.next()); if (removeGot) { diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/Assert.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/Assert.java index 4a7bfd8..bfc6474 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/Assert.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/Assert.java @@ -128,7 +128,7 @@ public class Assert { */ public static void notEmpty(String argumentName, String argumentObject) { notNull(argumentName, argumentObject); - if (argumentObject.length() == 0) { + if (argumentObject.isEmpty()) { throw new IllegalArgumentException(argumentName + " cannot be empty"); } } @@ -142,7 +142,7 @@ public class Assert { */ public static <T extends Map<?, ?>> void notEmpty(String argumentName, T argumentObject) { notNull(argumentName, argumentObject); - if (argumentObject.size() == 0) { + if (argumentObject.isEmpty()) { throw new IllegalArgumentException(argumentName + " cannot be empty"); } } @@ -156,7 +156,7 @@ public class Assert { */ public static <T extends Collection<?>> void notEmpty(String argumentName, T argumentObject) { notNull(argumentName, argumentObject); - if (argumentObject.size() == 0) { + if (argumentObject.isEmpty()) { throw new IllegalArgumentException(argumentName + " cannot be empty"); } } diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/FileUtil.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/FileUtil.java index 11ae20b..5c06cdd 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/FileUtil.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/FileUtil.java @@ -465,7 +465,7 @@ public final class FileUtil { } if (hasAllPathStrings && name.endsWith("." + fileExtension)) { - if (stringsToFindInFile.size() == 0) { + if (stringsToFindInFile.isEmpty()) { return true; } StringBuffer xmlFileBuffer = null; diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectType.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectType.java index 62078de..f6b2018 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectType.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectType.java @@ -318,7 +318,7 @@ public class ObjectType { if (sourceClass.equals(targetClass)) { return obj; } - if (obj instanceof String && ((String) obj).length() == 0) { + if (obj instanceof String && ((String) obj).isEmpty()) { return null; } Converter<Object, Object> converter = null; @@ -461,13 +461,13 @@ public class ObjectType { if (convertedValue1 == null) { return Boolean.TRUE; } - if (convertedValue1 instanceof String && ((String) convertedValue1).length() == 0) { + if (convertedValue1 instanceof String && ((String) convertedValue1).isEmpty()) { return Boolean.TRUE; } - if (convertedValue1 instanceof List<?> && ((List<?>) convertedValue1).size() == 0) { + if (convertedValue1 instanceof List<?> && ((List<?>) convertedValue1).isEmpty()) { return Boolean.TRUE; } - if (convertedValue1 instanceof Map<?, ?> && ((Map<?, ?>) convertedValue1).size() == 0) { + if (convertedValue1 instanceof Map<?, ?> && ((Map<?, ?>) convertedValue1).isEmpty()) { return Boolean.TRUE; } return Boolean.FALSE; @@ -475,13 +475,13 @@ public class ObjectType { if (convertedValue1 == null) { return Boolean.FALSE; } - if (convertedValue1 instanceof String && ((String) convertedValue1).length() == 0) { + if (convertedValue1 instanceof String && ((String) convertedValue1).isEmpty()) { return Boolean.FALSE; } - if (convertedValue1 instanceof List<?> && ((List<?>) convertedValue1).size() == 0) { + if (convertedValue1 instanceof List<?> && ((List<?>) convertedValue1).isEmpty()) { return Boolean.FALSE; } - if (convertedValue1 instanceof Map<?, ?> && ((Map<?, ?>) convertedValue1).size() == 0) { + if (convertedValue1 instanceof Map<?, ?> && ((Map<?, ?>) convertedValue1).isEmpty()) { return Boolean.FALSE; } return Boolean.TRUE; @@ -491,11 +491,11 @@ public class ObjectType { String str1 = (String) convertedValue1; String str2 = (String) convertedValue2; - if (str1.length() == 0 || str2.length() == 0) { + if (str1.isEmpty() || str2.isEmpty()) { if ("equals".equals(operator)) { - return str1.length() == 0 && str2.length() == 0 ? Boolean.TRUE : Boolean.FALSE; + return str1.isEmpty() && str2.isEmpty() ? Boolean.TRUE : Boolean.FALSE; } else if ("not-equals".equals(operator)) { - return str1.length() == 0 && str2.length() == 0 ? Boolean.FALSE : Boolean.TRUE; + return str1.isEmpty() && str2.isEmpty() ? Boolean.FALSE : Boolean.TRUE; } else { messages.add("ERROR: Could not do a compare between strings with one empty string for the operator " + operator); return Boolean.FALSE; @@ -603,13 +603,13 @@ public class ObjectType { } if (value instanceof String) { - return ((String) value).length() == 0; + return ((String) value).isEmpty(); } if (value instanceof Collection) { - return ((Collection<? extends Object>) value).size() == 0; + return ((Collection<? extends Object>) value).isEmpty(); } if (value instanceof Map) { - return ((Map<? extends Object, ? extends Object>) value).size() == 0; + return ((Map<? extends Object, ? extends Object>) value).isEmpty(); } if (value instanceof CharSequence) { return ((CharSequence) value).length() == 0; diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/ScriptUtil.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/ScriptUtil.java index 66da395..28bb36b 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/ScriptUtil.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/ScriptUtil.java @@ -86,14 +86,14 @@ public final class ScriptUtil { Debug.logInfo(" Version: " + engine.getEngineVersion(), MODULE); Debug.logInfo(" Language: " + engine.getLanguageName(), MODULE); List<String> extensions = engine.getExtensions(); - if (extensions.size() > 0) { + if (!extensions.isEmpty()) { Debug.logInfo(" Engine supports the following extensions:", MODULE); for (String e : extensions) { Debug.logInfo(" " + e, MODULE); } } List<String> shortNames = engine.getNames(); - if (shortNames.size() > 0) { + if (!shortNames.isEmpty()) { Debug.logInfo(" Engine has the following short names:", MODULE); for (String name : engine.getNames()) { writableScriptNames.add(name); diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/StringUtil.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/StringUtil.java index 9c490a7..e36aaf5 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/StringUtil.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/StringUtil.java @@ -399,7 +399,7 @@ public class StringUtil { if (theString == null) { return null; } - if (theString.length() == 0) { + if (theString.isEmpty()) { return StringWrapper.EMPTY_STRING_WRAPPER; } return new StringWrapper(theString); diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilProperties.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilProperties.java index 58bca03..370d872 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilProperties.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilProperties.java @@ -1019,7 +1019,7 @@ public final class UtilProperties implements Serializable { List<Locale> candidateLocales = getCandidateLocales(locale); UtilResourceBundle parentBundle = null; int numProperties = 0; - while (candidateLocales.size() > 0) { + while (!candidateLocales.isEmpty()) { Locale candidateLocale = candidateLocales.remove(candidateLocales.size() - 1); // ResourceBundles are connected together as a singly-linked list String lookupName = createResourceName(resource, candidateLocale, true); diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/FlexibleServletAccessor.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/FlexibleServletAccessor.java index 42ea403..32ab094 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/FlexibleServletAccessor.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/FlexibleServletAccessor.java @@ -240,7 +240,7 @@ public class FlexibleServletAccessor<T> implements Serializable { if (openBrace != -1 && closeBrace != -1) { String liStr = attributeName.substring(openBrace + 1, closeBrace); //if brackets are empty, append to list - if (liStr.length() == 0) { + if (liStr.isEmpty()) { isAddAtEnd = true; } else { if (liStr.charAt(0) == '+') { diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/ResourceBundleMapWrapper.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/ResourceBundleMapWrapper.java index 3389185..e5e63b9 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/ResourceBundleMapWrapper.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/ResourceBundleMapWrapper.java @@ -225,7 +225,7 @@ public class ResourceBundleMapWrapper implements Map<String, Object>, Serializab if (isMapInitialized) { return topLevelMap.isEmpty(); } - return resourceBundle.keySet().size() == 0; + return resourceBundle.keySet().isEmpty(); } @Override diff --git a/framework/common/src/main/java/org/apache/ofbiz/common/CommonServices.java b/framework/common/src/main/java/org/apache/ofbiz/common/CommonServices.java index c3a7210..8eaee14 100644 --- a/framework/common/src/main/java/org/apache/ofbiz/common/CommonServices.java +++ b/framework/common/src/main/java/org/apache/ofbiz/common/CommonServices.java @@ -82,7 +82,7 @@ public class CommonServices { public static Map<String, Object> testService(DispatchContext dctx, Map<String, ?> context) { Map<String, Object> response = ServiceUtil.returnSuccess(); - if (context.size() > 0) { + if (!context.isEmpty()) { for (Map.Entry<String, ?> entry: context.entrySet()) { Object cKey = entry.getKey(); Object value = entry.getValue(); diff --git a/framework/common/src/main/java/org/apache/ofbiz/common/FindServices.java b/framework/common/src/main/java/org/apache/ofbiz/common/FindServices.java index 6445e79..2440a91 100644 --- a/framework/common/src/main/java/org/apache/ofbiz/common/FindServices.java +++ b/framework/common/src/main/java/org/apache/ofbiz/common/FindServices.java @@ -306,7 +306,7 @@ public class FindServices { for (String groupedConditions : savedGroups.keySet()) { orConditions.add(EntityCondition.makeCondition(savedGroups.get(groupedConditions))); } - if (orConditions.size() > 0) result.add(EntityCondition.makeCondition(orConditions, EntityOperator.OR)); + if (!orConditions.isEmpty()) result.add(EntityCondition.makeCondition(orConditions, EntityOperator.OR)); return result; } @@ -608,7 +608,7 @@ public class FindServices { * the user has specified a noConditionFind. Otherwise, specifying filterByDate will become * its own condition. */ - if (tmpList.size() > 0 || "Y".equals(noConditionFind)) { + if (!tmpList.isEmpty() || "Y".equals(noConditionFind)) { if ("Y".equals(filterByDate)) { queryStringMap.put("filterByDate", filterByDate); if (UtilValidate.isEmpty(fromDateName)) { @@ -633,7 +633,7 @@ public class FindServices { } EntityConditionList<EntityCondition> exprList = null; - if (tmpList.size() > 0) { + if (!tmpList.isEmpty()) { exprList = EntityCondition.makeCondition(tmpList); } diff --git a/framework/common/src/main/java/org/apache/ofbiz/common/FtpServices.java b/framework/common/src/main/java/org/apache/ofbiz/common/FtpServices.java index e70c5ba..1d7352e 100644 --- a/framework/common/src/main/java/org/apache/ofbiz/common/FtpServices.java +++ b/framework/common/src/main/java/org/apache/ofbiz/common/FtpServices.java @@ -120,7 +120,7 @@ public class FtpServices { Debug.logWarning(e, "[putFile] Problem with FTP disconnect: ", MODULE); } } - if (errorList.size() > 0) { + if (!errorList.isEmpty()) { Debug.logError("[putFile] The following error(s) (" + errorList.size() + ") occurred: " + errorList, MODULE); return ServiceUtil.returnError(errorList); } @@ -183,7 +183,7 @@ public class FtpServices { Debug.logWarning(e, "[getFile] Problem with FTP disconnect: ", MODULE); } } - if (errorList.size() > 0) { + if (!errorList.isEmpty()) { Debug.logError("[getFile] The following error(s) (" + errorList.size() + ") occurred: " + errorList, MODULE); return ServiceUtil.returnError(errorList); } diff --git a/framework/common/src/main/java/org/apache/ofbiz/common/KeywordSearchUtil.java b/framework/common/src/main/java/org/apache/ofbiz/common/KeywordSearchUtil.java index a8bebe6..3f297bd 100644 --- a/framework/common/src/main/java/org/apache/ofbiz/common/KeywordSearchUtil.java +++ b/framework/common/src/main/java/org/apache/ofbiz/common/KeywordSearchUtil.java @@ -140,7 +140,7 @@ public final class KeywordSearchUtil { } // get rid of all length 0 tokens now - if (token.length() == 0) { + if (token.isEmpty()) { continue; } @@ -182,7 +182,7 @@ public final class KeywordSearchUtil { } Set<String> keywords = new TreeSet<>(); - if (str.length() > 0) { + if (!str.isEmpty()) { // strip off weird characters str = str.replaceAll("\\\302\\\240|\\\240", " "); diff --git a/framework/common/src/main/java/org/apache/ofbiz/common/image/ImageTransform.java b/framework/common/src/main/java/org/apache/ofbiz/common/image/ImageTransform.java index fc68c9b..3257afb 100644 --- a/framework/common/src/main/java/org/apache/ofbiz/common/image/ImageTransform.java +++ b/framework/common/src/main/java/org/apache/ofbiz/common/image/ImageTransform.java @@ -247,7 +247,7 @@ public class ImageTransform { for (Element currentElt : children) { Map<String, String> eltMap = new LinkedHashMap<>(); List<? extends Element> children2 = UtilXml.childElementList(currentElt); - if (children2.size() > 0) { + if (!children2.isEmpty()) { Map<String, String> childMap = new LinkedHashMap<>(); // loop over Children 1st level for (Element currentChild : children2) { diff --git a/framework/common/src/main/java/org/apache/ofbiz/common/login/LoginServices.java b/framework/common/src/main/java/org/apache/ofbiz/common/login/LoginServices.java index 8ff7336..3d6d07b 100644 --- a/framework/common/src/main/java/org/apache/ofbiz/common/login/LoginServices.java +++ b/framework/common/src/main/java/org/apache/ofbiz/common/login/LoginServices.java @@ -440,7 +440,7 @@ public class LoginServices { } } - if (errMsg.length() > 0) { + if (!errMsg.isEmpty()) { result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_FAIL); result.put(ModelService.ERROR_MESSAGE, errMsg); } @@ -693,7 +693,7 @@ public class LoginServices { errorMessageList.add(errMsg); } - if (errorMessageList.size() > 0) { + if (!errorMessageList.isEmpty()) { return ServiceUtil.returnError(errorMessageList); } @@ -812,7 +812,7 @@ public class LoginServices { checkNewPassword(userLoginToUpdate, currentPassword, newPassword, newPasswordVerify, passwordHint, errorMessageList, adminUser, locale); } - if (errorMessageList.size() > 0) { + if (!errorMessageList.isEmpty()) { return ServiceUtil.returnError(errorMessageList); } @@ -920,7 +920,7 @@ public class LoginServices { newUserLogin.set("enabled", "Y"); newUserLogin.set("disabledDateTime", null); - if (errorMessageList.size() > 0) { + if (!errorMessageList.isEmpty()) { return ServiceUtil.returnError(errorMessageList); } diff --git a/framework/common/src/main/java/org/apache/ofbiz/common/status/StatusWorker.java b/framework/common/src/main/java/org/apache/ofbiz/common/status/StatusWorker.java index 57cfb45..8ca947e 100644 --- a/framework/common/src/main/java/org/apache/ofbiz/common/status/StatusWorker.java +++ b/framework/common/src/main/java/org/apache/ofbiz/common/status/StatusWorker.java @@ -84,7 +84,7 @@ public final class StatusWorker { Debug.logError(e, MODULE); } - if (statusItems.size() > 0) + if (!statusItems.isEmpty()) pageContext.setAttribute(attributeName, statusItems); } diff --git a/framework/datafile/src/main/java/org/apache/ofbiz/datafile/DataFile2EntityXml.java b/framework/datafile/src/main/java/org/apache/ofbiz/datafile/DataFile2EntityXml.java index b8b2baa..183358b 100644 --- a/framework/datafile/src/main/java/org/apache/ofbiz/datafile/DataFile2EntityXml.java +++ b/framework/datafile/src/main/java/org/apache/ofbiz/datafile/DataFile2EntityXml.java @@ -67,7 +67,7 @@ public class DataFile2EntityXml { } if (value instanceof String) { value = ((String) value).trim(); - if (((String) value).length() == 0) { + if (((String) value).isEmpty()) { value = modelField.getDefaultValue(); } } diff --git a/framework/datafile/src/main/java/org/apache/ofbiz/datafile/ModelDataFileReader.java b/framework/datafile/src/main/java/org/apache/ofbiz/datafile/ModelDataFileReader.java index f513ff1..660fe74 100644 --- a/framework/datafile/src/main/java/org/apache/ofbiz/datafile/ModelDataFileReader.java +++ b/framework/datafile/src/main/java/org/apache/ofbiz/datafile/ModelDataFileReader.java @@ -146,7 +146,7 @@ public final class ModelDataFileReader { } docElement.normalize(); List<? extends Element> dataFileElements = UtilXml.childElementList(docElement, "data-file"); - if (dataFileElements.size() == 0) { + if (dataFileElements.isEmpty()) { Debug.logWarning("No <data-file> elements found in " + this.readerURL, MODULE); throw new DataFileException("No <data-file> elements found in " + this.readerURL); } diff --git a/framework/datafile/src/main/java/org/apache/ofbiz/datafile/RecordIterator.java b/framework/datafile/src/main/java/org/apache/ofbiz/datafile/RecordIterator.java index 67f5174..3d94d1b 100644 --- a/framework/datafile/src/main/java/org/apache/ofbiz/datafile/RecordIterator.java +++ b/framework/datafile/src/main/java/org/apache/ofbiz/datafile/RecordIterator.java @@ -198,7 +198,7 @@ public class RecordIterator { // if parent equals top parent on stack, add to that parents child list, otherwise pop off parent and try again Record parentRecord = null; - while (parentStack.size() > 0) { + while (!parentStack.isEmpty()) { parentRecord = parentStack.peek(); if (parentRecord.getRecordName().equals(this.nextRecord.getModelRecord().getParentName())) { break; diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericDelegator.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericDelegator.java index 3e34097..ab97c3b 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericDelegator.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericDelegator.java @@ -152,7 +152,7 @@ public class GenericDelegator implements Delegator { public static String popUserIdentifier() { List<String> curValList = getUserIdentifierStack(); - if (curValList.size() == 0) { + if (curValList.isEmpty()) { return null; } return curValList.remove(0); @@ -182,7 +182,7 @@ public class GenericDelegator implements Delegator { public static String popSessionIdentifier() { List<String> curValList = getSessionIdentifierStack(); - if (curValList.size() == 0) { + if (curValList.isEmpty()) { return null; } return curValList.remove(0); @@ -237,7 +237,7 @@ public class GenericDelegator implements Delegator { List<String> warningList = new LinkedList<>(); Debug.logInfo("Doing entity definition check...", MODULE); ModelEntityChecker.checkEntities(this, warningList); - if (warningList.size() > 0) { + if (!warningList.isEmpty()) { Debug.logWarning("=-=-=-=-= Found " + warningList.size() + " warnings when checking the entity definitions:", MODULE); for (String warning: warningList) { Debug.logWarning(warning, MODULE); @@ -2813,12 +2813,12 @@ public class GenericDelegator implements Delegator { @Override public String getCurrentSessionIdentifier() { List<String> curValList = getSessionIdentifierStack(); - return curValList.size() > 0 ? curValList.get(0) : null; + return !curValList.isEmpty() ? curValList.get(0) : null; } @Override public String getCurrentUserIdentifier() { List<String> curValList = getUserIdentifierStack(); - return curValList.size() > 0 ? curValList.get(0) : null; + return !curValList.isEmpty() ? curValList.get(0) : null; } } diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericEntity.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericEntity.java index f677669..2d76ea0 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericEntity.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericEntity.java @@ -987,7 +987,7 @@ public class GenericEntity implements Map<String, Object>, LocalizedMap<Object>, if (setIfEmpty) { // if empty string, set to null - if (field != null && field instanceof String && ((String) field).length() == 0) { + if (field != null && field instanceof String && ((String) field).isEmpty()) { this.set(curField.getName(), null); } else { this.set(curField.getName(), field); @@ -999,7 +999,7 @@ public class GenericEntity implements Map<String, Object>, LocalizedMap<Object>, if (field instanceof String) { String fieldStr = (String) field; - if (fieldStr.length() > 0) { + if (!fieldStr.isEmpty()) { this.set(curField.getName(), fieldStr); } } else { @@ -1287,7 +1287,7 @@ public class GenericEntity implements Map<String, Object>, LocalizedMap<Object>, } } - if (cdataMap.size() == 0) { + if (cdataMap.isEmpty()) { writer.println("/>"); } else { writer.println('>'); diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionSubSelect.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionSubSelect.java index 4723843..ce1b1fa 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionSubSelect.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionSubSelect.java @@ -86,8 +86,8 @@ public class EntityConditionSubSelect extends EntityConditionValue { } String viewClause = SqlJdbcUtil.makeViewWhereClause(localModelEntity, (datasourceInfo != null ? datasourceInfo.getJoinStyle() : null)); - if (viewClause.length() > 0) { - if (entityCondWhereString.length() > 0) { + if (!viewClause.isEmpty()) { + if (!entityCondWhereString.isEmpty()) { whereString.append("("); whereString.append(entityCondWhereString); whereString.append(") AND "); diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityExpr.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityExpr.java index 4768ece..5c5dc5d 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityExpr.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityExpr.java @@ -185,7 +185,7 @@ public final class EntityExpr implements EntityCondition { if (value instanceof Collection<?>) { Collection<?> valueCol = UtilGenerics.cast(value); - if (valueCol.size() > 0) { + if (!valueCol.isEmpty()) { value = valueCol.iterator().next(); } else { value = null; diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/datasource/GenericDAO.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/datasource/GenericDAO.java index 77073b8..2c0e008 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/datasource/GenericDAO.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/datasource/GenericDAO.java @@ -427,7 +427,7 @@ public class GenericDAO { // Got results 0 -> INSERT, 1 -> UPDATE, >1 -> View is nor updatable GenericValue meGenericValue = null; - if (meResult.size() == 0) { + if (meResult.isEmpty()) { // Create new value to insert try { // Create new value to store @@ -472,10 +472,10 @@ public class GenericDAO { * This avoids partial creation of member entities, which would mean data inconsistency: * If not all member entities can be updated, then none should be updated */ - if (meResult.size() == 0) { + if (meResult.isEmpty()) { retVal += singleInsert(meGenericValue, memberModelEntity, memberModelEntity.getFieldsUnmodifiable(), sqlP); } else { - if (meFieldsToSave.size() > 0) { + if (!meFieldsToSave.isEmpty()) { retVal += singleUpdate(meGenericValue, memberModelEntity, meFieldsToSave, sqlP); } else { if (Debug.verboseOn()) { @@ -557,13 +557,13 @@ public class GenericDAO { } } - if (tempKeys.size() > 0) { + if (!tempKeys.isEmpty()) { throw new GenericModelException("In partialSelect invalid field names specified: " + tempKeys.toString()); } StringBuilder sqlBuffer = new StringBuilder("SELECT "); - if (partialFields.size() > 0) { + if (!partialFields.isEmpty()) { modelEntity.colNameString(partialFields, sqlBuffer, "", ", ", "", datasource.getAliasViewColumns()); } else { sqlBuffer.append("*"); @@ -652,7 +652,7 @@ public class GenericDAO { } } - if (tempKeys.size() > 0) { + if (!tempKeys.isEmpty()) { throw new GenericModelException("In selectListIteratorByCondition invalid field names specified: " + tempKeys.toString()); } fieldSetsToInclude.remove(""); @@ -696,7 +696,7 @@ public class GenericDAO { sqlBuffer.append("DISTINCT "); } - if (selectFields.size() > 0) { + if (!selectFields.isEmpty()) { modelEntity.colNameString(selectFields, sqlBuffer, "", ", ", "", datasource.getAliasViewColumns()); } else { sqlBuffer.append("*"); @@ -821,7 +821,7 @@ public class GenericDAO { String viewClause = SqlJdbcUtil.makeViewWhereClause(modelEntity, datasource.getJoinStyle()); - if (viewClause.length() > 0) { + if (!viewClause.isEmpty()) { conditions.add(EntityCondition.makeConditionWhere(viewClause)); } @@ -1056,7 +1056,7 @@ public class GenericDAO { * cause the "COUNT(DISTINCT " to appear twice, causing an attempt to try to count a count (function="count-distinct", distinct=true in * find options) */ - if (selectFields != null && selectFields.size() > 0) { + if (selectFields != null && !selectFields.isEmpty()) { ModelField firstSelectField = selectFields.get(0); ModelViewEntity.ModelAlias firstModelAlias = modelViewEntity != null ? modelViewEntity.getAlias(firstSelectField.getName()) : null; if (firstModelAlias != null && UtilValidate.isNotEmpty(firstModelAlias.getFunction())) { diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/finder/EntityFinderUtil.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/finder/EntityFinderUtil.java index 64676e6..b950a10 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/finder/EntityFinderUtil.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/finder/EntityFinderUtil.java @@ -64,7 +64,7 @@ public final class EntityFinderUtil { public static Map<FlexibleMapAccessor<Object>, Object> makeFieldMap(Element element) { Map<FlexibleMapAccessor<Object>, Object> fieldMap = null; List<? extends Element> fieldMapElementList = UtilXml.childElementList(element, "field-map"); - if (fieldMapElementList.size() > 0) { + if (!fieldMapElementList.isEmpty()) { fieldMap = new HashMap<>(fieldMapElementList.size()); for (Element fieldMapElement: fieldMapElementList) { // set the env-name for each field-name, noting that if no field-name is specified it defaults to the env-name @@ -117,7 +117,7 @@ public final class EntityFinderUtil { public static List<FlexibleStringExpander> makeSelectFieldExpanderList(Element element) { List<FlexibleStringExpander> selectFieldExpanderList = null; List<? extends Element> selectFieldElementList = UtilXml.childElementList(element, "select-field"); - if (selectFieldElementList.size() > 0) { + if (!selectFieldElementList.isEmpty()) { selectFieldExpanderList = new ArrayList<>(selectFieldElementList.size()); for (Element selectFieldElement: selectFieldElementList) { selectFieldExpanderList.add(FlexibleStringExpander.getInstance(selectFieldElement.getAttribute("field-name"))); diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/finder/ListFinder.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/finder/ListFinder.java index fd56b9e..4797c8e 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/finder/ListFinder.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/finder/ListFinder.java @@ -87,7 +87,7 @@ public abstract class ListFinder extends Finder { // process order-by List<? extends Element> orderByElementList = UtilXml.childElementList(element, "order-by"); - if (orderByElementList.size() > 0) { + if (!orderByElementList.isEmpty()) { orderByExpanderList = new ArrayList<>(orderByElementList.size()); for (Element orderByElement : orderByElementList) { orderByExpanderList.add(FlexibleStringExpander.getInstance(orderByElement.getAttribute("field-name"))); diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/DatabaseUtil.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/DatabaseUtil.java index 4bfb1d1..a6d9c1e 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/DatabaseUtil.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/DatabaseUtil.java @@ -1098,7 +1098,7 @@ public class DatabaseUtil { private Map<String, Map<String, ColumnCheckInfo>> getColumnInfo(Set<String> tableNames, boolean getPks, Collection<String> messages, ExecutorService executor) { // if there are no tableNames, don't even try to get the columns - if (tableNames.size() == 0) { + if (tableNames.isEmpty()) { return new HashMap<>(); } diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/SqlJdbcUtil.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/SqlJdbcUtil.java index c933332..a1b320f 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/SqlJdbcUtil.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/SqlJdbcUtil.java @@ -367,7 +367,7 @@ public final class SqlJdbcUtil { String viewClause = makeViewWhereClause(modelEntity, joinStyle); - if (viewClause.length() > 0) { + if (!viewClause.isEmpty()) { if (whereString.length() > 0) { whereString.append(' '); whereString.append(operator); diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/model/DynamicViewEntity.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/model/DynamicViewEntity.java index dadadb0..778632f 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/model/DynamicViewEntity.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/model/DynamicViewEntity.java @@ -168,7 +168,7 @@ public class DynamicViewEntity { */ public String getOneRealEntityName() { // return first entity name for memberModelMemberEntities Map - if (this.memberModelMemberEntities.size() == 0) { + if (this.memberModelMemberEntities.isEmpty()) { return null; } diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/model/ModelEntity.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/model/ModelEntity.java index b224810..24dab21 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/model/ModelEntity.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/model/ModelEntity.java @@ -1977,7 +1977,7 @@ public class ModelEntity implements Comparable<ModelEntity>, Serializable { } } } - if (relationshipsMapList.size() > 0) { + if (!relationshipsMapList.isEmpty()) { topLevelMap.put("relationships", relationshipsMapList); } diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/model/ModelReader.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/model/ModelReader.java index 56750b3..773120d 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/model/ModelReader.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/model/ModelReader.java @@ -427,7 +427,7 @@ public class ModelReader implements Serializable { } } - if (newSameEntityRelations.size() > 0) { + if (!newSameEntityRelations.isEmpty()) { for (ModelRelation newRel : newSameEntityRelations) { curModelEntity.addRelation(newRel); } @@ -610,10 +610,10 @@ public class ModelReader implements Serializable { return null; } Set<String> allEntities = this.getEntityNames(); - while (!allEntities.contains(entityName) && entityName.length() > 0) { + while (!allEntities.contains(entityName) && !entityName.isEmpty()) { entityName = entityName.substring(1); } - return (entityName.length() > 0 ? entityName : null); + return (!entityName.isEmpty() ? entityName : null); } ModelEntity createModelEntity(Element entityElement, UtilTimer utilTimer, ModelInfo def) { diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/model/ModelViewEntity.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/model/ModelViewEntity.java index 0101ca8..cfec11b 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/model/ModelViewEntity.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/model/ModelViewEntity.java @@ -1112,7 +1112,7 @@ public class ModelViewEntity extends ModelEntity { @Override public void makeAliasColName(StringBuilder colNameBuffer, StringBuilder fieldTypeBuffer, ModelViewEntity modelViewEntity, ModelReader modelReader) { - if (complexAliasMembers.size() == 0) { + if (complexAliasMembers.isEmpty()) { return; } else if (complexAliasMembers.size() == 1) { ComplexAliasMember complexAliasMember = complexAliasMembers.iterator().next(); @@ -1375,7 +1375,7 @@ public class ModelViewEntity extends ModelEntity { this.distinct = "true".equals(element.getAttribute("distinct")); // process order-by List<? extends Element> orderByElementList = UtilXml.childElementList(element, "order-by"); - if (orderByElementList.size() > 0) { + if (!orderByElementList.isEmpty()) { orderByList = new ArrayList<>(orderByElementList.size()); for (Element orderByElement: orderByElementList) { orderByList.add(orderByElement.getAttribute("field-name")); @@ -1608,7 +1608,7 @@ public class ModelViewEntity extends ModelEntity { @Override public EntityCondition createCondition(ModelFieldTypeReader modelFieldTypeReader, List<String> entityAliasStack) { - if (this.conditionList.size() == 0) { + if (this.conditionList.isEmpty()) { return null; } if (this.conditionList.size() == 1) { diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/transaction/TransactionUtil.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/transaction/TransactionUtil.java index 1e89b49..9df54c4 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/transaction/TransactionUtil.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/transaction/TransactionUtil.java @@ -872,7 +872,7 @@ public final class TransactionUtil implements Status { */ private static void popTransactionStartStamp(Transaction t) { Map<Transaction, Timestamp> map = suspendedTxStartStamps.get(); - if (map.size() > 0) { + if (!map.isEmpty()) { Timestamp stamp = map.remove(t); if (stamp != null) { transactionStartStamp.set(stamp); diff --git a/framework/entityext/src/main/java/org/apache/ofbiz/entityext/EntityGroupUtil.java b/framework/entityext/src/main/java/org/apache/ofbiz/entityext/EntityGroupUtil.java index ecfa206..2324161 100644 --- a/framework/entityext/src/main/java/org/apache/ofbiz/entityext/EntityGroupUtil.java +++ b/framework/entityext/src/main/java/org/apache/ofbiz/entityext/EntityGroupUtil.java @@ -69,7 +69,7 @@ public final class EntityGroupUtil { } // if there are no includes records, always include; otherwise check each one to make sure at least one matches - if (entityGroupEntryValues.size() == 0) { + if (entityGroupEntryValues.isEmpty()) { entityModelToUseList.add(modelEntity); } else { // we have different types of include applications: ESIA_INCLUDE, ESIA_EXCLUDE, ESIA_ALWAYS diff --git a/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/EntityDataServices.java b/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/EntityDataServices.java index 9f5ada4..e55c7ad 100644 --- a/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/EntityDataServices.java +++ b/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/EntityDataServices.java @@ -310,7 +310,7 @@ public class EntityDataServices { value = value.trim(); } - if (value != null && value.length() == 0) { + if (value != null && value.isEmpty()) { value = null; } } else { @@ -378,7 +378,7 @@ public class EntityDataServices { Debug.logImportant("Updating column field size changes", MODULE); List<String> fieldsWrongSize = new LinkedList<>(); dbUtil.checkDb(modelEntities, fieldsWrongSize, messages, true, true, true, true); - if (fieldsWrongSize.size() > 0) { + if (!fieldsWrongSize.isEmpty()) { dbUtil.repairColumnSizeChanges(modelEntities, fieldsWrongSize, messages); } else { String thisMsg = "No field sizes to update"; diff --git a/framework/entityext/src/main/java/org/apache/ofbiz/entityext/eca/EntityEcaCondition.java b/framework/entityext/src/main/java/org/apache/ofbiz/entityext/eca/EntityEcaCondition.java index acd2eb1..44450ea 100644 --- a/framework/entityext/src/main/java/org/apache/ofbiz/entityext/eca/EntityEcaCondition.java +++ b/framework/entityext/src/main/java/org/apache/ofbiz/entityext/eca/EntityEcaCondition.java @@ -118,7 +118,7 @@ public final class EntityEcaCondition implements java.io.Serializable { Boolean cond = ObjectType.doRealCompare(lhsValue, rhsValue, operator, compareType, format, messages, null, dctx.getClassLoader(), constant); // if any messages were returned send them out - if (messages.size() > 0) { + if (!messages.isEmpty()) { for (Object message: messages) { Debug.logWarning((String) message, MODULE); } diff --git a/framework/entityext/src/main/java/org/apache/ofbiz/entityext/permission/EntityPermissionChecker.java b/framework/entityext/src/main/java/org/apache/ofbiz/entityext/permission/EntityPermissionChecker.java index b9a7851..698c445 100644 --- a/framework/entityext/src/main/java/org/apache/ofbiz/entityext/permission/EntityPermissionChecker.java +++ b/framework/entityext/src/main/java/org/apache/ofbiz/entityext/permission/EntityPermissionChecker.java @@ -377,7 +377,7 @@ public class EntityPermissionChecker { statusId = entity.getString("statusId"); } - if (purposeList.size() > 0) { + if (!purposeList.isEmpty()) { passed = hasMatch(entityName, targetOperationEntityList, roleList, hasPurposeOp, purposeList, hasStatusOp, statusId); } if (passed) { @@ -924,7 +924,7 @@ public class EntityPermissionChecker { Debug.logError(e, "Problem finding PartyRelationships. ", MODULE); return false; } - if (partyRelationships.size() > 0) { + if (!partyRelationships.isEmpty()) { isMember = true; } @@ -1317,7 +1317,7 @@ public class EntityPermissionChecker { List<String> ownedContentIdList = new LinkedList<>(); getEntityOwners(delegator, entity, ownedContentIdList, this.entityName, this.ownerEntityFieldName); - if (ownedContentIdList.size() > 0) { + if (!ownedContentIdList.isEmpty()) { List<String> lst = getUserRolesFromList(delegator, ownedContentIdList, partyId, this.roleEntityIdName, this.partyFieldName, this.roleTypeFieldName, this.roleEntityName); this.roleIdList.addAll(lst); diff --git a/framework/entityext/src/main/java/org/apache/ofbiz/entityext/synchronization/EntitySyncContext.java b/framework/entityext/src/main/java/org/apache/ofbiz/entityext/synchronization/EntitySyncContext.java index a11812d..37b2d7b 100644 --- a/framework/entityext/src/main/java/org/apache/ofbiz/entityext/synchronization/EntitySyncContext.java +++ b/framework/entityext/src/main/java/org/apache/ofbiz/entityext/synchronization/EntitySyncContext.java @@ -537,7 +537,7 @@ public class EntitySyncContext { // TEST SECTION: leave false for normal use boolean logValues = false; - if (logValues && valuesToCreate.size() > 0) { + if (logValues && !valuesToCreate.isEmpty()) { StringBuilder toCreateInfo = new StringBuilder(); for (GenericValue valueToCreate: valuesToCreate) { toCreateInfo.append("\n-->["); @@ -552,7 +552,7 @@ public class EntitySyncContext { // As the this.nextCreateTxTime calculation is only based on entities without values to create, if there at least one value to create returned // this calculation is false, so it needs to be nullified - if (valuesToCreate.size() > 0) { + if (!valuesToCreate.isEmpty()) { this.nextCreateTxTime = null; } @@ -704,7 +704,7 @@ public class EntitySyncContext { // TEST SECTION: leave false for normal use boolean logValues = false; - if (logValues && valuesToStore.size() > 0) { + if (logValues && !valuesToStore.isEmpty()) { StringBuilder toStoreInfo = new StringBuilder(); for (GenericValue valueToStore: valuesToStore) { toStoreInfo.append("\n-->["); @@ -719,7 +719,7 @@ public class EntitySyncContext { // As the this.nextUpdateTxTime calculation is only based on entities without values to store, if there at least one value to store returned // this calculation is false, so it needs to be nullified - if (valuesToStore.size() > 0) { + if (!valuesToStore.isEmpty()) { this.nextUpdateTxTime = null; } @@ -788,7 +788,7 @@ public class EntitySyncContext { removeEli.close(); // if we didn't find anything for this entity, find the next value's Timestamp and keep track of it - if (keysToRemove.size() == 0) { + if (keysToRemove.isEmpty()) { EntityCondition findNextCondition = EntityCondition.makeCondition(ModelEntity.STAMP_TX_FIELD, EntityOperator.GREATER_THAN_EQUAL_TO, currentRunEndTime); EntityListIterator eliNext = EntityQuery.use(delegator) @@ -830,7 +830,7 @@ public class EntitySyncContext { // TEST SECTION: leave false for normal use boolean logValues = false; - if (logValues && keysToRemove.size() > 0) { + if (logValues && !keysToRemove.isEmpty()) { StringBuilder toRemoveInfo = new StringBuilder(); for (GenericEntity keyToRemove: keysToRemove) { toRemoveInfo.append("\n-->["); @@ -845,7 +845,7 @@ public class EntitySyncContext { // As this.nextRemoveTxTime calculation is only based on entities without keys to remove, if there at least one key to remove returned // this calculation is false, so it needs to be nullified - if (keysToRemove.size() > 0) { + if (!keysToRemove.isEmpty()) { this.nextRemoveTxTime = null; } return keysToRemove; diff --git a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/MiniLangUtil.java b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/MiniLangUtil.java index dac846e..cad9ff8 100644 --- a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/MiniLangUtil.java +++ b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/MiniLangUtil.java @@ -76,7 +76,7 @@ public final class MiniLangUtil { * @return <code>true</code> if <code>str</code> contains a script */ public static boolean containsScript(String str) { - if (str.length() > 0) { + if (!str.isEmpty()) { for (String scriptPrefix : SCRIPT_PREFIXES) { if (str.contains(scriptPrefix)) { return true; @@ -230,7 +230,7 @@ public final class MiniLangUtil { * constant value */ public static boolean isConstantAttribute(String attributeValue) { - if (attributeValue.length() > 0) { + if (!attributeValue.isEmpty()) { return !FlexibleStringExpander.containsExpression(FlexibleStringExpander.getInstance(attributeValue)); } return true; @@ -245,7 +245,7 @@ public final class MiniLangUtil { * constant value or a constant plus expression value */ public static boolean isConstantPlusExpressionAttribute(String attributeValue) { - if (attributeValue.length() > 0) { + if (!attributeValue.isEmpty()) { if (attributeValue.startsWith("${") && attributeValue.endsWith("}")) { // A lot of existing code uses concatenated expressions, and they can be difficult // to convert to a single expression, so we will allow them for now. diff --git a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/MiniLangValidate.java b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/MiniLangValidate.java index 3493a10..e7fbb36 100644 --- a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/MiniLangValidate.java +++ b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/MiniLangValidate.java @@ -136,7 +136,7 @@ public final class MiniLangValidate { */ public static void deprecatedAttribute(SimpleMethod method, Element element, String attributeName, String fixInstruction) throws ValidationException { String attributeValue = element.getAttribute(attributeName); - if (attributeValue.length() > 0) { + if (!attributeValue.isEmpty()) { handleError("Attribute \"" + attributeName + "\" is deprecated (" + fixInstruction + ")", method, element); } } @@ -151,7 +151,7 @@ public final class MiniLangValidate { public static void expressionAttributes(SimpleMethod method, Element element, String... attributeNames) throws ValidationException { for (String name : attributeNames) { String attributeValue = element.getAttribute(name); - if (attributeValue.length() > 0) { + if (!attributeValue.isEmpty()) { if (attributeValue.startsWith("${") && attributeValue.endsWith("}")) { attributeValue = attributeValue.substring(2, attributeValue.length() - 1); } @@ -214,7 +214,7 @@ public final class MiniLangValidate { StringBuilder sb = new StringBuilder(); for (String name : attributeNames) { String attributeValue = element.getAttribute(name); - if (attributeValue.length() > 0) { + if (!attributeValue.isEmpty()) { return; } if (sb.length() > 0) { @@ -265,7 +265,7 @@ public final class MiniLangValidate { public static void requiredAttributes(SimpleMethod method, Element element, String... attributeNames) throws ValidationException { for (String name : attributeNames) { String attributeValue = element.getAttribute(name); - if (attributeValue.length() == 0) { + if (attributeValue.isEmpty()) { handleError("Required attribute \"" + name + "\" is missing.", method, element); } } @@ -305,7 +305,7 @@ public final class MiniLangValidate { public static void scriptAttributes(SimpleMethod method, Element element, String... attributeNames) throws ValidationException { for (String name : attributeNames) { String attributeValue = element.getAttribute(name).trim(); - if (attributeValue.length() > 0) { + if (!attributeValue.isEmpty()) { if (attributeValue.startsWith("${") && attributeValue.endsWith("}")) { handleError("Script attribute \"" + name + "\" enclosed in \"${}\" (remove enclosing ${}).", method, element); } diff --git a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/SimpleMethod.java b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/SimpleMethod.java index e20544a..a9932bd 100644 --- a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/SimpleMethod.java +++ b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/SimpleMethod.java @@ -508,7 +508,7 @@ public final class SimpleMethod extends MiniLangElement { if (methodContext.getMethodType() == MethodContext.EVENT) { boolean forceError = false; String tempErrorMsg = (String) methodContext.getEnv(eventErrorMessageName); - if (errorMsg.length() > 0 || UtilValidate.isNotEmpty(tempErrorMsg)) { + if (!errorMsg.isEmpty() || UtilValidate.isNotEmpty(tempErrorMsg)) { errorMsg += tempErrorMsg; methodContext.getRequest().setAttribute("_ERROR_MESSAGE_", errorMsg); forceError = true; @@ -547,7 +547,7 @@ public final class SimpleMethod extends MiniLangElement { } else { boolean forceError = false; String tempErrorMsg = (String) methodContext.getEnv(serviceErrorMessageName); - if (errorMsg.length() > 0 || UtilValidate.isNotEmpty(tempErrorMsg)) { + if (!errorMsg.isEmpty() || UtilValidate.isNotEmpty(tempErrorMsg)) { errorMsg += tempErrorMsg; methodContext.putResult(ModelService.ERROR_MESSAGE, errorMsg); forceError = true; diff --git a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/CallClassMethod.java b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/CallClassMethod.java index d10d8b6..d2cd7ab 100644 --- a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/CallClassMethod.java +++ b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/CallClassMethod.java @@ -71,7 +71,7 @@ public final class CallClassMethod extends MethodOperation { this.methodName = element.getAttribute("method-name"); this.retFieldFma = FlexibleMapAccessor.getInstance(element.getAttribute("ret-field")); List<? extends Element> parameterElements = UtilXml.childElementList(element); - if (parameterElements.size() > 0) { + if (!parameterElements.isEmpty()) { ArrayList<MethodObject<?>> parameterList = new ArrayList<>(parameterElements.size()); for (Element parameterElement : parameterElements) { if ("string".equals(parameterElement.getNodeName())) { diff --git a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/CallObjectMethod.java b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/CallObjectMethod.java index 1ff3f8b..38dbd0a 100644 --- a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/CallObjectMethod.java +++ b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/CallObjectMethod.java @@ -62,7 +62,7 @@ public final class CallObjectMethod extends MethodOperation { this.objFieldFma = FlexibleMapAccessor.getInstance(element.getAttribute("obj-field")); this.retFieldFma = FlexibleMapAccessor.getInstance(element.getAttribute("ret-field")); List<? extends Element> parameterElements = UtilXml.childElementList(element); - if (parameterElements.size() > 0) { + if (!parameterElements.isEmpty()) { ArrayList<MethodObject<?>> parameterList = new ArrayList<>(parameterElements.size()); for (Element parameterElement : parameterElements) { if ("string".equals(parameterElement.getNodeName())) { diff --git a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/CallScript.java b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/CallScript.java index cba6203..0e2abd2 100644 --- a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/CallScript.java +++ b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/CallScript.java @@ -42,7 +42,7 @@ public final class CallScript extends MethodOperation { // This method is needed only during the v1 to v2 transition private static boolean autoCorrect(Element element) { String errorListAttr = element.getAttribute("error-list-name"); - if (errorListAttr.length() > 0) { + if (!errorListAttr.isEmpty()) { element.removeAttribute("error-list-name"); return true; } diff --git a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/CallSimpleMethod.java b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/CallSimpleMethod.java index 05bde28..3d1e314 100644 --- a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/CallSimpleMethod.java +++ b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/CallSimpleMethod.java @@ -176,13 +176,13 @@ public final class CallSimpleMethod extends MethodOperation { @Override public String toString() { StringBuilder sb = new StringBuilder("<call-simple-method "); - if (this.methodName.length() > 0) { + if (!this.methodName.isEmpty()) { sb.append("method-name=\"").append(this.methodName).append("\" "); } - if (this.xmlResource.length() > 0) { + if (!this.xmlResource.isEmpty()) { sb.append("xml-resource=\"").append(this.xmlResource).append("\" "); } - if (this.scope.length() > 0) { + if (!this.scope.isEmpty()) { sb.append("scope=\"").append(this.scope).append("\" "); } sb.append("/>"); @@ -218,7 +218,7 @@ public final class CallSimpleMethod extends MethodOperation { } this.resultNameFma = FlexibleMapAccessor.getInstance(element.getAttribute("result-name")); String fieldAttribute = element.getAttribute("field"); - if (fieldAttribute.length() == 0) { + if (fieldAttribute.isEmpty()) { this.fieldFma = this.resultNameFma; } else { this.fieldFma = FlexibleMapAccessor.getInstance(fieldAttribute); diff --git a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/SetServiceFields.java b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/SetServiceFields.java index 829ba60..f79c44e 100644 --- a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/SetServiceFields.java +++ b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/SetServiceFields.java @@ -104,7 +104,7 @@ public final class SetServiceFields extends MethodOperation { } List<Object> errorMessages = new LinkedList<>(); Map<String, Object> validAttributes = modelService.makeValid(fromMap, mode, true, errorMessages, methodContext.getTimeZone(), methodContext.getLocale()); - if (errorMessages.size() > 0) { + if (!errorMessages.isEmpty()) { for (Object obj : errorMessages) { simpleMethod.addErrorMessage(methodContext, (String) obj); } diff --git a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/conditional/CombinedCondition.java b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/conditional/CombinedCondition.java index 1a930ba..4bded57 100644 --- a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/conditional/CombinedCondition.java +++ b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/conditional/CombinedCondition.java @@ -69,7 +69,7 @@ public abstract class CombinedCondition extends MiniLangElement implements Condi return new CombinedCondition(element, simpleMethod) { @Override public boolean checkCondition(MethodContext methodContext) throws MiniLangException { - if (subConditions.size() == 0) + if (subConditions.isEmpty()) return true; for (Conditional subCond : subConditions) { if (!subCond.checkCondition(methodContext)) { @@ -100,7 +100,7 @@ public abstract class CombinedCondition extends MiniLangElement implements Condi return new CombinedCondition(element, simpleMethod) { @Override public boolean checkCondition(MethodContext methodContext) throws MiniLangException { - if (subConditions.size() == 0) + if (subConditions.isEmpty()) return true; Conditional subCond = subConditions.get(0); return !subCond.checkCondition(methodContext); @@ -108,7 +108,7 @@ public abstract class CombinedCondition extends MiniLangElement implements Condi @Override public void prettyPrint(StringBuilder messageBuffer, MethodContext methodContext) { messageBuffer.append("( NOT "); - if (subConditions.size() > 0) { + if (!subConditions.isEmpty()) { Conditional subCond = subConditions.get(0); subCond.prettyPrint(messageBuffer, methodContext); } @@ -132,7 +132,7 @@ public abstract class CombinedCondition extends MiniLangElement implements Condi return new CombinedCondition(element, simpleMethod) { @Override public boolean checkCondition(MethodContext methodContext) throws MiniLangException { - if (subConditions.size() == 0) + if (subConditions.isEmpty()) return true; for (Conditional subCond : subConditions) { if (subCond.checkCondition(methodContext)) { @@ -163,7 +163,7 @@ public abstract class CombinedCondition extends MiniLangElement implements Condi return new CombinedCondition(element, simpleMethod) { @Override public boolean checkCondition(MethodContext methodContext) throws MiniLangException { - if (subConditions.size() == 0) + if (subConditions.isEmpty()) return true; boolean trueFound = false; for (Conditional subCond : subConditions) { diff --git a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/CheckErrors.java b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/CheckErrors.java index 7184b05..04e6de8 100644 --- a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/CheckErrors.java +++ b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/CheckErrors.java @@ -53,7 +53,7 @@ public final class CheckErrors extends MethodOperation { outputTraceMessage(methodContext, "Begin check-errors."); } List<Object> messages = methodContext.getEnv(this.errorListNameFse.expandString(methodContext.getEnvMap())); - if (messages != null && messages.size() > 0) { + if (messages != null && !messages.isEmpty()) { if (methodContext.getMethodType() == MethodContext.EVENT) { methodContext.putEnv(simpleMethod.getEventErrorMessageListName(), messages); methodContext.putEnv(this.simpleMethod.getEventResponseCodeName(), getErrorCode(methodContext)); diff --git a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/CreateObject.java b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/CreateObject.java index cdeaa56..c0c3da1 100644 --- a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/CreateObject.java +++ b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/CreateObject.java @@ -70,7 +70,7 @@ public final class CreateObject extends MethodOperation { this.targetClass = targetClass; fieldFma = FlexibleMapAccessor.getInstance(element.getAttribute("field")); List<? extends Element> parameterElements = UtilXml.childElementList(element); - if (parameterElements.size() > 0) { + if (!parameterElements.isEmpty()) { ArrayList<MethodObject<?>> parameterList = new ArrayList<>(parameterElements.size()); for (Element parameterElement : parameterElements) { if ("string".equals(parameterElement.getNodeName())) { diff --git a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/Iterate.java b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/Iterate.java index 5f16b5c..0f51294 100644 --- a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/Iterate.java +++ b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/Iterate.java @@ -100,7 +100,7 @@ public final class Iterate extends MethodOperation { } } else if (objList instanceof Collection<?>) { Collection<Object> theCollection = UtilGenerics.cast(objList); - if (theCollection.size() == 0) { + if (theCollection.isEmpty()) { if (Debug.verboseOn()) { Debug.logVerbose("Collection has zero entries, doing nothing: " + this, MODULE); } diff --git a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/IterateMap.java b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/IterateMap.java index e5a1a57..9488665 100644 --- a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/IterateMap.java +++ b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/IterateMap.java @@ -85,7 +85,7 @@ public final class IterateMap extends MethodOperation { } return true; } - if (theMap.size() == 0) { + if (theMap.isEmpty()) { if (Debug.verboseOn()) { Debug.logVerbose("Map with name " + mapFma + " has zero entries, doing nothing: " + this, MODULE); } diff --git a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/OrderMapList.java b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/OrderMapList.java index c4bd8c9..db0b96b 100644 --- a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/OrderMapList.java +++ b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/OrderMapList.java @@ -53,7 +53,7 @@ public final class OrderMapList extends MethodOperation { } listFma = FlexibleMapAccessor.getInstance(element.getAttribute("list")); List<? extends Element> orderByElements = UtilXml.childElementList(element, "order-by"); - if (orderByElements.size() > 0) { + if (!orderByElements.isEmpty()) { List<FlexibleMapAccessor<String>> orderByList = new ArrayList<>(orderByElements.size()); for (Element orderByElement : orderByElements) { FlexibleMapAccessor<String> fma = FlexibleMapAccessor.getInstance(orderByElement.getAttribute("field")); diff --git a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/SetCalendar.java b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/SetCalendar.java index 0231d55..82ec73c 100644 --- a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/SetCalendar.java +++ b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/SetCalendar.java @@ -53,14 +53,14 @@ public final class SetCalendar extends MethodOperation { boolean elementModified = false; // Correct deprecated default-value attribute String defaultAttr = element.getAttribute("default-value"); - if (defaultAttr.length() > 0) { + if (!defaultAttr.isEmpty()) { element.setAttribute("default", defaultAttr); element.removeAttribute("default-value"); elementModified = true; } // Correct deprecated from-field attribute String fromAttr = element.getAttribute("from-field"); - if (fromAttr.length() > 0) { + if (!fromAttr.isEmpty()) { element.setAttribute("from", fromAttr); element.removeAttribute("from-field"); elementModified = true; diff --git a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/SetOperation.java b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/SetOperation.java index 2d8e010..042c9e5 100644 --- a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/SetOperation.java +++ b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/SetOperation.java @@ -49,14 +49,14 @@ public final class SetOperation extends MethodOperation { boolean elementModified = false; // Correct deprecated default-value attribute String defaultAttr = element.getAttribute("default-value"); - if (defaultAttr.length() > 0) { + if (!defaultAttr.isEmpty()) { element.setAttribute("default", defaultAttr); element.removeAttribute("default-value"); elementModified = true; } // Correct deprecated from-field attribute String fromAttr = element.getAttribute("from-field"); - if (fromAttr.length() > 0) { + if (!fromAttr.isEmpty()) { element.setAttribute("from", fromAttr); element.removeAttribute("from-field"); elementModified = true; @@ -169,7 +169,7 @@ public final class SetOperation extends MethodOperation { } return true; } - if (this.type.length() > 0) { + if (!this.type.isEmpty()) { if ("NewMap".equals(this.type)) { newValue = new HashMap<String, Object>(); } else if ("NewList".equals(this.type)) { @@ -224,7 +224,7 @@ public final class SetOperation extends MethodOperation { if (!this.defaultFse.isEmpty()) { sb.append("default=\"").append(this.defaultFse).append("\" "); } - if (this.type.length() > 0) { + if (!this.type.isEmpty()) { sb.append("type=\"").append(this.type).append("\" "); } if (this.setIfNull) { diff --git a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/eventops/RequestParametersToList.java b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/eventops/RequestParametersToList.java index c469752..42cae57 100644 --- a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/eventops/RequestParametersToList.java +++ b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/eventops/RequestParametersToList.java @@ -41,7 +41,7 @@ public final class RequestParametersToList extends MethodOperation { private static boolean autoCorrect(Element element) { // Correct deprecated list-name attribute String listAttr = element.getAttribute("list-name"); - if (listAttr.length() > 0) { + if (!listAttr.isEmpty()) { element.setAttribute("list", listAttr); element.removeAttribute("list-name"); return true; diff --git a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/otherops/Log.java b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/otherops/Log.java index 530dfe3..21dc0f6 100644 --- a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/otherops/Log.java +++ b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/otherops/Log.java @@ -51,7 +51,7 @@ public final class Log extends MethodOperation { } this.messageFse = FlexibleStringExpander.getInstance(element.getAttribute("message")); String levelAttribute = UtilXml.getAttributeValueIgnorePrefix(element, "level"); - if (levelAttribute.length() == 0) { + if (levelAttribute.isEmpty()) { levelAttribute = "info"; } Integer levelInt = Debug.getLevelFromString(levelAttribute); diff --git a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/otherops/PropertyToField.java b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/otherops/PropertyToField.java index 0c34c63..7e4d5e6 100644 --- a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/otherops/PropertyToField.java +++ b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/otherops/PropertyToField.java @@ -43,7 +43,7 @@ public final class PropertyToField extends MethodOperation { private static boolean autoCorrect(Element element) { // Correct deprecated arg-list-name attribute String listAttr = element.getAttribute("arg-list-name"); - if (listAttr.length() > 0) { + if (!listAttr.isEmpty()) { element.setAttribute("arg-list", listAttr); element.removeAttribute("arg-list-name"); return true; diff --git a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/serviceops/FieldToResult.java b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/serviceops/FieldToResult.java index d52afd8..85e875a 100644 --- a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/serviceops/FieldToResult.java +++ b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/serviceops/FieldToResult.java @@ -48,7 +48,7 @@ public final class FieldToResult extends MethodOperation { } this.fieldFma = FlexibleMapAccessor.getInstance(element.getAttribute("field")); String resultNameAttribute = element.getAttribute("result-name"); - if (resultNameAttribute.length() == 0) { + if (resultNameAttribute.isEmpty()) { this.resultFma = this.fieldFma; } else { this.resultFma = FlexibleMapAccessor.getInstance(resultNameAttribute); diff --git a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/operation/Convert.java b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/operation/Convert.java index 8d772f5..83536d6 100644 --- a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/operation/Convert.java +++ b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/operation/Convert.java @@ -67,7 +67,7 @@ public class Convert extends SimpleMapOperation { // if an incoming string is empty, // set to null if setIfNull is true, otherwise do nothing, ie treat as if null if (fieldObject instanceof java.lang.String) { - if (((String) fieldObject).length() == 0) { + if (((String) fieldObject).isEmpty()) { if (setIfNull && (replace || !results.containsKey(toField))) results.put(toField, null); return; diff --git a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/operation/Copy.java b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/operation/Copy.java index 7188fa5..0af5a5a 100644 --- a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/operation/Copy.java +++ b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/operation/Copy.java @@ -53,7 +53,7 @@ public class Copy extends SimpleMapOperation { return; } if (fieldValue instanceof java.lang.String) { - if (((String) fieldValue).length() == 0) { + if (((String) fieldValue).isEmpty()) { if (setIfNull && (replace || !results.containsKey(toField))) { results.put(toField, null); } diff --git a/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java b/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java index ce6b47a..e00a525 100644 --- a/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java +++ b/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java @@ -1169,7 +1169,7 @@ public class ModelService extends AbstractMap<String, Object> implements Seriali } // check for requiredButNull fields and return an error since null values are not allowed for required fields - if (requiredButNull.size() > 0) { + if (!requiredButNull.isEmpty()) { List<String> missingMsg = new LinkedList<>(); for (String missingKey: requiredButNull) { String message = this.getParam(missingKey).getPrimaryFailMessage(locale); @@ -1228,7 +1228,7 @@ public class ModelService extends AbstractMap<String, Object> implements Seriali } } } - if (errorMessageList.size() > 0) { + if (!errorMessageList.isEmpty()) { throw new ServiceValidationException(errorMessageList, this, mode); } } @@ -1266,7 +1266,7 @@ public class ModelService extends AbstractMap<String, Object> implements Seriali Set<String> keySet = info.keySet(); // Quick check for sizes - if (info.size() == 0 && test.size() == 0) { + if (info.isEmpty() && test.isEmpty()) { return; } // This is to see if the test set contains all from the info set (reverse) @@ -1359,7 +1359,7 @@ public class ModelService extends AbstractMap<String, Object> implements Seriali } } - if (typeFailMsgs.size() > 0) { + if (!typeFailMsgs.isEmpty()) { throw new ServiceValidationException(typeFailMsgs, model, mode); } } @@ -1441,7 +1441,7 @@ public class ModelService extends AbstractMap<String, Object> implements Seriali if (!IN_PARAM.equals(mode) && !OUT_PARAM.equals(mode) && !IN_OUT_PARAM.equals(mode)) { return names; } - if (contextInfo.size() == 0) { + if (contextInfo.isEmpty()) { return names; } for (ModelParam param: contextParamList) { @@ -1520,7 +1520,7 @@ public class ModelService extends AbstractMap<String, Object> implements Seriali if (!IN_PARAM.equals(mode) && !OUT_PARAM.equals(mode) && !IN_OUT_PARAM.equals(mode)) { return target; } - if (contextInfo.size() == 0) { + if (contextInfo.isEmpty()) { return target; } @@ -1727,7 +1727,7 @@ public class ModelService extends AbstractMap<String, Object> implements Seriali public synchronized void interfaceUpdate(DispatchContext dctx) throws GenericServiceException { if (!inheritedParameters) { // services w/ engine 'group' auto-implement the grouped services - if ("group".equals(this.engineName) && implServices.size() == 0) { + if ("group".equals(this.engineName) && implServices.isEmpty()) { GroupModel group = internalGroup; if (group == null) { group = ServiceGroupReader.getGroupModel(this.location); diff --git a/framework/service/src/main/java/org/apache/ofbiz/service/ModelServiceReader.java b/framework/service/src/main/java/org/apache/ofbiz/service/ModelServiceReader.java index 6259d3f..f08214e 100644 --- a/framework/service/src/main/java/org/apache/ofbiz/service/ModelServiceReader.java +++ b/framework/service/src/main/java/org/apache/ofbiz/service/ModelServiceReader.java @@ -381,7 +381,7 @@ public class ModelServiceReader implements Serializable { for (Element implement: UtilXml.childElementList(baseElement, "implements")) { String serviceName = UtilXml.checkEmpty(implement.getAttribute("service")).intern(); boolean optional = UtilXml.checkBoolean(implement.getAttribute("optional"), false); - if (serviceName.length() > 0) { + if (!serviceName.isEmpty()) { service.getImplServices().add(new ModelServiceIface(serviceName, optional)); } } diff --git a/framework/service/src/main/java/org/apache/ofbiz/service/ServiceDispatcher.java b/framework/service/src/main/java/org/apache/ofbiz/service/ServiceDispatcher.java index f9def66..3ba63ca 100644 --- a/framework/service/src/main/java/org/apache/ofbiz/service/ServiceDispatcher.java +++ b/framework/service/src/main/java/org/apache/ofbiz/service/ServiceDispatcher.java @@ -195,7 +195,7 @@ public final class ServiceDispatcher { public void deregister(LocalDispatcher local) { Debug.logInfo("De-Registering dispatcher: " + local.getName(), MODULE); localContext.remove(local.getName()); - if (localContext.size() == 0) { + if (localContext.isEmpty()) { try { this.shutdown(); } catch (GenericServiceException e) { diff --git a/framework/service/src/main/java/org/apache/ofbiz/service/ServiceUtil.java b/framework/service/src/main/java/org/apache/ofbiz/service/ServiceUtil.java index 704da49..6c67ac4 100644 --- a/framework/service/src/main/java/org/apache/ofbiz/service/ServiceUtil.java +++ b/framework/service/src/main/java/org/apache/ofbiz/service/ServiceUtil.java @@ -128,10 +128,10 @@ public final class ServiceUtil { } } - if (errorList.size() > 0) { + if (!errorList.isEmpty()) { result.put(ModelService.ERROR_MESSAGE_LIST, errorList); } - if (errorMap.size() > 0) { + if (!errorMap.isEmpty()) { result.put(ModelService.ERROR_MESSAGE_MAP, errorMap); } Debug.logError(result.toString(), MODULE); diff --git a/framework/service/src/main/java/org/apache/ofbiz/service/calendar/RecurrenceRule.java b/framework/service/src/main/java/org/apache/ofbiz/service/calendar/RecurrenceRule.java index 29c3006..421aba4 100644 --- a/framework/service/src/main/java/org/apache/ofbiz/service/calendar/RecurrenceRule.java +++ b/framework/service/src/main/java/org/apache/ofbiz/service/calendar/RecurrenceRule.java @@ -736,7 +736,7 @@ public class RecurrenceRule { } String numberStr = numberBuf.toString(); - if (numberStr.length() > 0 && (numberStr.length() > 1 || (numberStr.charAt(0) != '+' && numberStr.charAt(0) != '-'))) { + if (!numberStr.isEmpty() && (numberStr.length() > 1 || (numberStr.charAt(0) != '+' && numberStr.charAt(0) != '-'))) { try { number = Integer.parseInt(numberStr); } catch (NumberFormatException nfe) { diff --git a/framework/service/src/main/java/org/apache/ofbiz/service/calendar/TemporalExpressions.java b/framework/service/src/main/java/org/apache/ofbiz/service/calendar/TemporalExpressions.java index 7378b79..3a62744 100644 --- a/framework/service/src/main/java/org/apache/ofbiz/service/calendar/TemporalExpressions.java +++ b/framework/service/src/main/java/org/apache/ofbiz/service/calendar/TemporalExpressions.java @@ -995,7 +995,7 @@ public class TemporalExpressions implements Serializable { if (containsExpression(this)) { throw new IllegalArgumentException("recursive expression"); } - if (this.expressionSet.size() > 0) { + if (!this.expressionSet.isEmpty()) { // Aggregate member expression sequences in a way that will // ensure the proper evaluation sequence for the entire collection int result = 0; @@ -1563,7 +1563,7 @@ public class TemporalExpressions implements Serializable { if (containsExpression(this)) { throw new IllegalArgumentException("recursive expression"); } - if (this.expressionSet.size() > 0) { + if (!this.expressionSet.isEmpty()) { TemporalExpression that = this.expressionSet.iterator().next(); this.sequence = that.sequence; } diff --git a/framework/service/src/main/java/org/apache/ofbiz/service/eca/ServiceEcaCondition.java b/framework/service/src/main/java/org/apache/ofbiz/service/eca/ServiceEcaCondition.java index 3d6bfa1..a264f51 100644 --- a/framework/service/src/main/java/org/apache/ofbiz/service/eca/ServiceEcaCondition.java +++ b/framework/service/src/main/java/org/apache/ofbiz/service/eca/ServiceEcaCondition.java @@ -184,7 +184,7 @@ public class ServiceEcaCondition implements java.io.Serializable { Boolean cond = ObjectType.doRealCompare(lhsValue, rhsValue, operator, compareType, format, messages, null, dctx.getClassLoader(), isConstant); // if any messages were returned send them out - if (messages.size() > 0 && Debug.warningOn()) { + if (!messages.isEmpty() && Debug.warningOn()) { for (Object message: messages) { Debug.logWarning(message.toString(), MODULE); } diff --git a/framework/service/src/main/java/org/apache/ofbiz/service/group/GroupModel.java b/framework/service/src/main/java/org/apache/ofbiz/service/group/GroupModel.java index ce7c700..1b7b941 100644 --- a/framework/service/src/main/java/org/apache/ofbiz/service/group/GroupModel.java +++ b/framework/service/src/main/java/org/apache/ofbiz/service/group/GroupModel.java @@ -62,7 +62,7 @@ public class GroupModel { } List<? extends Element> oldServiceTags = UtilXml.childElementList(group, "service"); - if (oldServiceTags.size() > 0) { + if (!oldServiceTags.isEmpty()) { for (Element service : oldServiceTags) { services.add(new GroupServiceModel(service)); } diff --git a/framework/service/src/main/java/org/apache/ofbiz/service/group/GroupServiceModel.java b/framework/service/src/main/java/org/apache/ofbiz/service/group/GroupServiceModel.java index c786282..a5c6acb 100644 --- a/framework/service/src/main/java/org/apache/ofbiz/service/group/GroupServiceModel.java +++ b/framework/service/src/main/java/org/apache/ofbiz/service/group/GroupServiceModel.java @@ -109,7 +109,7 @@ public class GroupServiceModel { Debug.logInfo("Running grouped service [" + serviceName + "]", MODULE); if ("async".equals(getMode())) { List<String> requiredOut = model.getParameterNames(ModelService.OUT_PARAM, false); - if (requiredOut.size() > 0) { + if (!requiredOut.isEmpty()) { Debug.logWarning("Grouped service (" + getName() + ") requested 'async' invocation; running sync because of required OUT parameters.", MODULE); return dispatcher.runSync(localName, model, thisContext); } diff --git a/framework/service/src/main/java/org/apache/ofbiz/service/group/ServiceGroupReader.java b/framework/service/src/main/java/org/apache/ofbiz/service/group/ServiceGroupReader.java index 9913df3..2fff430 100644 --- a/framework/service/src/main/java/org/apache/ofbiz/service/group/ServiceGroupReader.java +++ b/framework/service/src/main/java/org/apache/ofbiz/service/group/ServiceGroupReader.java @@ -96,7 +96,7 @@ public final class ServiceGroupReader { } public static GroupModel getGroupModel(String serviceName) { - if (GROUPS_CACHE.size() == 0) { + if (GROUPS_CACHE.isEmpty()) { ServiceGroupReader.readConfig(); } return GROUPS_CACHE.get(serviceName); diff --git a/framework/service/src/main/java/org/apache/ofbiz/service/mail/ServiceMcaUtil.java b/framework/service/src/main/java/org/apache/ofbiz/service/mail/ServiceMcaUtil.java index 67c7a3e..4af9640 100644 --- a/framework/service/src/main/java/org/apache/ofbiz/service/mail/ServiceMcaUtil.java +++ b/framework/service/src/main/java/org/apache/ofbiz/service/mail/ServiceMcaUtil.java @@ -82,7 +82,7 @@ public final class ServiceMcaUtil { } public static Collection<ServiceMcaRule> getServiceMcaRules() { - if (mcaCache.size() == 0) { + if (mcaCache.isEmpty()) { readConfig(); } return mcaCache.values(); diff --git a/framework/service/src/main/java/org/apache/ofbiz/service/test/ServiceEngineTestServices.java b/framework/service/src/main/java/org/apache/ofbiz/service/test/ServiceEngineTestServices.java index 7608265..4233d35 100644 --- a/framework/service/src/main/java/org/apache/ofbiz/service/test/ServiceEngineTestServices.java +++ b/framework/service/src/main/java/org/apache/ofbiz/service/test/ServiceEngineTestServices.java @@ -61,7 +61,7 @@ public class ServiceEngineTestServices { errorList.add(UtilProperties.getMessage(RESOURCE, "ServiceTestDeadLockThreadB", UtilMisc.toMap("errorString", ServiceUtil.getErrorMessage(threadBResult)), locale)); } - if (errorList.size() > 0) { + if (!errorList.isEmpty()) { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServiceTestDeadLockRetry", locale), errorList, null, null); } } catch (Exception e) { @@ -164,7 +164,7 @@ public class ServiceEngineTestServices { if (ServiceUtil.isError(waiterResult)) { errorList.add("Error running testServiceLockWaitTimeoutRetryWaiter: " + ServiceUtil.getErrorMessage(waiterResult)); } - if (errorList.size() > 0) { + if (!errorList.isEmpty()) { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ServiceTestLockWaitTimeoutRetry", locale), errorList, null, null); } } catch (Exception e) { diff --git a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java index 4afc412..ec67a560 100644 --- a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java +++ b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java @@ -252,7 +252,7 @@ public class RequestHandler { reqAttrMap.put(name, obj); } } - if (reqAttrMap.size() > 0) { + if (!reqAttrMap.isEmpty()) { byte[] reqAttrMapBytes = UtilObject.getBytes(reqAttrMap); if (reqAttrMapBytes != null) { req.getSession().setAttribute("_REQ_ATTR_MAP_", StringUtil.toHexString(reqAttrMapBytes)); @@ -558,7 +558,7 @@ public class RequestHandler { throw new EventHandlerException("Pre-Processor event [" + event.getInvoke() + "] did not return 'success'."); } else { // protect the view normally rendered and redirect to error response view returnString = returnString.replace(":_protect_:", ""); - if (returnString.length() > 0) { + if (!returnString.isEmpty()) { request.setAttribute("_ERROR_MESSAGE_", returnString); } eventReturn = null; diff --git a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/WebAppServletContextListener.java b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/WebAppServletContextListener.java index e743011..bc559a0 100644 --- a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/WebAppServletContextListener.java +++ b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/WebAppServletContextListener.java @@ -44,7 +44,7 @@ public class WebAppServletContextListener implements ServletContextListener { sessionCookieConfig.setSecure(true); sessionCookieConfig.setComment("Created by Apache OFBiz WebAppServletContextListener"); String cookieDomain = UtilProperties.getPropertyValue("url", "cookie.domain", ""); - if (cookieDomain.length() > 0) sessionCookieConfig.setDomain(cookieDomain); + if (!cookieDomain.isEmpty()) sessionCookieConfig.setDomain(cookieDomain); sessionCookieConfig.setMaxAge(60 * 60 * 24 * 365); sessionCookieConfig.setPath(servletContext.getContextPath()); } diff --git a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/CoreEvents.java b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/CoreEvents.java index 50f52b3..05475ea 100644 --- a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/CoreEvents.java +++ b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/CoreEvents.java @@ -193,7 +193,7 @@ public class CoreEvents { continue; } - if (value instanceof String && ((String) value).length() == 0) { + if (value instanceof String && ((String) value).isEmpty()) { // interpreting empty fields as null values for each in back end handling... value = null; } diff --git a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/ServiceEventHandler.java b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/ServiceEventHandler.java index 42f5e31..be48684 100644 --- a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/ServiceEventHandler.java +++ b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/ServiceEventHandler.java @@ -204,7 +204,7 @@ public class ServiceEventHandler implements EventHandler { continue; } - if (value instanceof String && ((String) value).length() == 0) { + if (value instanceof String && ((String) value).isEmpty()) { // interpreting empty fields as null values for each in back end handling... value = null; } @@ -218,7 +218,7 @@ public class ServiceEventHandler implements EventHandler { // proper X, return immediately with messages if there are any List<Object> errorMessages = new LinkedList<>(); serviceContext = model.makeValid(serviceContext, ModelService.IN_PARAM, true, errorMessages, timeZone, locale); - if (errorMessages.size() > 0) { + if (!errorMessages.isEmpty()) { // uh-oh, had some problems... request.setAttribute("_ERROR_MESSAGE_LIST_", errorMessages); return "error"; diff --git a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/ServiceMultiEventHandler.java b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/ServiceMultiEventHandler.java index 5f901e0..d05de39 100644 --- a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/ServiceMultiEventHandler.java +++ b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/ServiceMultiEventHandler.java @@ -275,7 +275,7 @@ public class ServiceMultiEventHandler implements EventHandler { continue; } - if (value instanceof String && ((String) value).length() == 0) { + if (value instanceof String && ((String) value).isEmpty()) { // interpreting empty fields as null values for each in back end handling... value = null; } @@ -374,7 +374,7 @@ public class ServiceMultiEventHandler implements EventHandler { } } } finally { - if (errorMessages.size() > 0) { + if (!errorMessages.isEmpty()) { if (eventGlobalTransaction) { // rollback the global transaction try { @@ -401,7 +401,7 @@ public class ServiceMultiEventHandler implements EventHandler { throw new EventHandlerException("Commit multi-service global transaction failed"); } } - if (successMessages.size() > 0) { + if (!successMessages.isEmpty()) { request.setAttribute("_EVENT_MESSAGE_LIST_", successMessages); } returnString = "success"; diff --git a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/ftl/OfbizContentTransform.java b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/ftl/OfbizContentTransform.java index e6f0b57..d0d3319 100644 --- a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/ftl/OfbizContentTransform.java +++ b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/ftl/OfbizContentTransform.java @@ -100,7 +100,7 @@ public class OfbizContentTransform implements TemplateTransformModel { StringBuilder newURL = new StringBuilder(); ContentUrlTag.appendContentPrefix(request, newURL); if ((newURL.length() > 0 && newURL.charAt(newURL.length() - 1) != '/') - && (requestUrl.length()> 0 && requestUrl.charAt(0) != '/')) { + && (!requestUrl.isEmpty() && requestUrl.charAt(0) != '/')) { newURL.append('/'); } diff --git a/framework/webtools/src/main/java/org/apache/ofbiz/webtools/GenericWebEvent.java b/framework/webtools/src/main/java/org/apache/ofbiz/webtools/GenericWebEvent.java index 89d3bd1..69ecc9b 100644 --- a/framework/webtools/src/main/java/org/apache/ofbiz/webtools/GenericWebEvent.java +++ b/framework/webtools/src/main/java/org/apache/ofbiz/webtools/GenericWebEvent.java @@ -180,7 +180,7 @@ public class GenericWebEvent { } } - if (errMsgPk.length() > 0) { + if (!errMsgPk.isEmpty()) { request.setAttribute("_ERROR_MESSAGE_", errMsgPk); return "error"; } @@ -238,7 +238,7 @@ public class GenericWebEvent { } } - if (errMsgNonPk.length() > 0) { + if (!errMsgNonPk.isEmpty()) { request.setAttribute("_ERROR_MESSAGE_", errMsgNonPk); return "error"; } @@ -336,7 +336,7 @@ public class GenericWebEvent { } } - if (errMsgParam.length() > 0) { + if (!errMsgParam.isEmpty()) { errMsgParam = UtilProperties.getMessage(ERR_RESOURCE, "genericWebEvent.following_error_occurred", locale) + errMsgParam; request.setAttribute("_ERROR_MESSAGE_", errMsgParam); diff --git a/framework/webtools/src/main/java/org/apache/ofbiz/webtools/WebToolsServices.java b/framework/webtools/src/main/java/org/apache/ofbiz/webtools/WebToolsServices.java index 0a40f30..a7c9c8e 100644 --- a/framework/webtools/src/main/java/org/apache/ofbiz/webtools/WebToolsServices.java +++ b/framework/webtools/src/main/java/org/apache/ofbiz/webtools/WebToolsServices.java @@ -256,7 +256,7 @@ public class WebToolsServices { int initialListSize = files.size(); int lastUnprocessedFilesCount = 0; List<File> unprocessedFiles = new LinkedList<>(); - while (files.size() > 0 + while (!files.isEmpty() && files.size() != lastUnprocessedFilesCount) { lastUnprocessedFilesCount = files.size(); unprocessedFiles = new LinkedList<>(); @@ -416,12 +416,12 @@ public class WebToolsServices { messages.add("=-=-=-=-=-=-= No data " + (checkDataOnly ? "check" : "load") + " files found."); } - if (infoMessages.size() > 0) { + if (!infoMessages.isEmpty()) { messages.add("=-=-=-=-=-=-= Here is a summary of the data " + (checkDataOnly ? "check" : "load") + ":"); messages.addAll(infoMessages); } - if (errorMessages.size() > 0) { + if (!errorMessages.isEmpty()) { messages.add("=-=-=-=-=-=-= The following errors occurred in the data " + (checkDataOnly ? "check" : "load") + ":"); messages.addAll(errorMessages); } diff --git a/framework/webtools/src/main/java/org/apache/ofbiz/webtools/artifactinfo/ServiceArtifactInfo.java b/framework/webtools/src/main/java/org/apache/ofbiz/webtools/artifactinfo/ServiceArtifactInfo.java index 40deee2..dbcf442 100644 --- a/framework/webtools/src/main/java/org/apache/ofbiz/webtools/artifactinfo/ServiceArtifactInfo.java +++ b/framework/webtools/src/main/java/org/apache/ofbiz/webtools/artifactinfo/ServiceArtifactInfo.java @@ -655,7 +655,7 @@ public class ServiceArtifactInfo extends ArtifactInfoBase { relationshipMap.put("isMandatory", "Y"); } - if (relationshipsMapList.size() > 0) { + if (!relationshipsMapList.isEmpty()) { topLevelMap.put("relationships", relationshipsMapList); } diff --git a/framework/webtools/src/main/java/org/apache/ofbiz/webtools/artifactinfo/ServiceEcaArtifactInfo.java b/framework/webtools/src/main/java/org/apache/ofbiz/webtools/artifactinfo/ServiceEcaArtifactInfo.java index 3489520..c3a0f6d 100644 --- a/framework/webtools/src/main/java/org/apache/ofbiz/webtools/artifactinfo/ServiceEcaArtifactInfo.java +++ b/framework/webtools/src/main/java/org/apache/ofbiz/webtools/artifactinfo/ServiceEcaArtifactInfo.java @@ -215,7 +215,7 @@ public class ServiceEcaArtifactInfo extends ArtifactInfoBase { relationshipMap.put("isMandatory", "Y"); } - if (relationshipsMapList.size() > 0) { + if (!relationshipsMapList.isEmpty()) { topLevelMap.put("relationships", relationshipsMapList); } diff --git a/framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/LabelReferences.java b/framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/LabelReferences.java index 0b8a2d0..a89963d 100644 --- a/framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/LabelReferences.java +++ b/framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/LabelReferences.java @@ -109,7 +109,7 @@ public class LabelReferences { */ public Map<String, Map<String, Integer>> getLabelReferences() throws IOException, SAXException, ParserConfigurationException, GenericServiceException { - if (this.labels.size() == 0) { + if (this.labels.isEmpty()) { // Nothing to search for return references; } diff --git a/framework/webtools/template/entity/ModelInduceFromDb.jsp b/framework/webtools/template/entity/ModelInduceFromDb.jsp index 24cb74c..f3c8240 100644 --- a/framework/webtools/template/entity/ModelInduceFromDb.jsp +++ b/framework/webtools/template/entity/ModelInduceFromDb.jsp @@ -49,7 +49,7 @@ It's the datasource name. It doesn't need to be associated with a GenericDAO dao = GenericDAO.getGenericDAO(new GenericHelperInfo(null, helperName)); List newEntList = dao.induceModelFromDb(messages); - if(messages.size() > 0) { + if(!messages.isEmpty()) { %> ERRORS: <% diff --git a/framework/webtools/template/entity/xmldsrawdump.jsp b/framework/webtools/template/entity/xmldsrawdump.jsp index 00a5838..b3017b4 100644 --- a/framework/webtools/template/entity/xmldsrawdump.jsp +++ b/framework/webtools/template/entity/xmldsrawdump.jsp @@ -33,7 +33,7 @@ under the License. response.setContentType("text/xml; charset=UTF-8"); //UtilXml.writeXmlDocument(, document); - if(passedEntityNames.size() > 0) { + if(!passedEntityNames.isEmpty()) { numberOfEntities = passedEntityNames.size(); PrintWriter writer = null; diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/AbstractModelAction.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/AbstractModelAction.java index 562c58c..951b1bd 100644 --- a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/AbstractModelAction.java +++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/AbstractModelAction.java @@ -769,7 +769,7 @@ public abstract class AbstractModelAction implements Serializable, ModelAction { for (int i = trailList.size(); i >= 0; i--) { List<String> subTrail = trailList.subList(0, i); String newKey = null; - if (subTrail.size() > 0) { + if (!subTrail.isEmpty()) { newKey = StringUtil.join(subTrail, "|") + "|" + originalName; } else { newKey = originalName; diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/AbstractModelCondition.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/AbstractModelCondition.java index a493f12..b76cbbe 100644 --- a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/AbstractModelCondition.java +++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/AbstractModelCondition.java @@ -246,7 +246,7 @@ public abstract class AbstractModelCondition implements Serializable, ModelCondi } List<Object> messages = new LinkedList<>(); Boolean resultBool = BaseCompare.doRealCompare(fieldVal, value, operator, type, format, messages, null, null, true); - if (messages.size() > 0) { + if (!messages.isEmpty()) { messages.add(0, "Error with comparison in if-compare between field [" + fieldAcsr.toString() + "] with value [" + fieldVal + "] and value [" + value + "] with operator [" + operator + "] and type [" + type + "]: "); @@ -326,7 +326,7 @@ public abstract class AbstractModelCondition implements Serializable, ModelCondi List<Object> messages = new LinkedList<>(); Boolean resultBool = BaseCompare.doRealCompare(fieldVal, toFieldVal, operator, type, format, messages, null, null, false); - if (messages.size() > 0) { + if (!messages.isEmpty()) { messages.add(0, "Error with comparison in if-compare-field between field [" + fieldAcsr.toString() + "] with value [" + fieldVal + "] and to-field [" + toFieldAcsr.toString() + "] with value [" + toFieldVal + "] with operator [" + operator + "] and type [" + type + "]: "); diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java index 3dcb562..484723e 100644 --- a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java +++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java @@ -664,7 +664,7 @@ public abstract class ModelForm extends ModelWidget { } } } - if (sortOrderFields.size() > 0) { + if (!sortOrderFields.isEmpty()) { List<ModelFormFieldBuilder> sortedFields = new ArrayList<>(); for (SortField sortField : sortOrderFields) { String fieldName = sortField.getFieldName(); diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormField.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormField.java index cc1e6d1..59ee56d 100644 --- a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormField.java +++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormField.java @@ -2269,7 +2269,7 @@ public class ModelFormField { // read all option and entity-options sub-elements, maintaining order ArrayList<OptionSource> optionSources = new ArrayList<>(); List<? extends Element> childElements = UtilXml.childElementList(element); - if (childElements.size() > 0) { + if (!childElements.isEmpty()) { for (Element childElement : childElements) { String childName = childElement.getLocalName(); if ("option".equals(childName)) { @@ -3581,7 +3581,7 @@ public class ModelFormField { @Override public void addOptionValues(List<OptionValue> optionValues, Map<String, Object> context, Delegator delegator) { List<? extends Object> dataList = UtilGenerics.cast(this.listAcsr.get(context)); - if (dataList != null && dataList.size() != 0) { + if (dataList != null && !dataList.isEmpty()) { for (Object data : dataList) { Map<String, Object> localContext = new HashMap<>(); localContext.putAll(context); diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelTree.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelTree.java index 560a776..9c3be0a 100644 --- a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelTree.java +++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelTree.java @@ -129,7 +129,7 @@ public class ModelTree extends ModelWidget { } this.postTrailOpenDepth = postTrailOpenDepth; List<? extends Element> nodeElements = UtilXml.childElementList(treeElement, "node"); - if (nodeElements.size() == 0) { + if (nodeElements.isEmpty()) { throw new IllegalArgumentException("No node elements found for the tree definition with name: " + getName()); } Map<String, ModelNode> nodeMap = new HashMap<>(); diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelWidgetCondition.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelWidgetCondition.java index 1d501e4..5e1ebd6 100644 --- a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelWidgetCondition.java +++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelWidgetCondition.java @@ -215,7 +215,7 @@ public abstract class ModelWidgetCondition implements Serializable { } List<Object> messages = new LinkedList<>(); Boolean resultBool = BaseCompare.doRealCompare(fieldVal, value, operator, type, format, messages, null, null, true); - if (messages.size() > 0) { + if (!messages.isEmpty()) { messages.add(0, "Error with comparison in if-compare between field [" + fieldAcsr.toString() + "] with value [" + fieldVal + "] and value [" + value + "] with operator [" + operator + "] and type [" + type + "]: "); @@ -270,7 +270,7 @@ public abstract class ModelWidgetCondition implements Serializable { List<Object> messages = new LinkedList<>(); Boolean resultBool = BaseCompare.doRealCompare(fieldVal, toFieldVal, operator, type, format, messages, null, null, false); - if (messages.size() > 0) { + if (!messages.isEmpty()) { messages.add(0, "Error with comparison in if-compare-field between field [" + fieldAcsr.toString() + "] with value [" + fieldVal + "] and to-field [" + toFieldAcsr.toString() + "] with value [" + toFieldVal + "] with operator [" + operator + "] and type [" + type + "]: "); diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ThemeFactory.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ThemeFactory.java index f1a854d..8a8d143 100644 --- a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ThemeFactory.java +++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ThemeFactory.java @@ -166,9 +166,9 @@ public class ThemeFactory { */ public static List<VisualTheme> getAvailableThemes(Delegator delegator, String visualThemeSetId) throws GenericEntityException { - if (themeVisualThemeIdCache.size() == 0) { + if (themeVisualThemeIdCache.isEmpty()) { synchronized (ThemeFactory.class) { - if (themeVisualThemeIdCache.size() == 0) { + if (themeVisualThemeIdCache.isEmpty()) { pullModelThemesFromXmlToCache(); } } diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java index 517b168..f2dbe37 100644 --- a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java +++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java @@ -370,7 +370,7 @@ public class FormRenderer { innerFormFields.add(modelFormField); } - if (innerFormFields.size() > 0) { + if (!innerFormFields.isEmpty()) { numOfColumns++; } @@ -394,7 +394,7 @@ public class FormRenderer { List<ModelFormField> mainFieldList = listsMap.get("mainFieldList"); int numOfCells = innerDisplayHyperlinkFieldsBegin.size() + innerDisplayHyperlinkFieldsEnd.size() - + (innerFormFields.size() > 0 ? 1 : 0); + + (!innerFormFields.isEmpty() ? 1 : 0); int numOfColumnsToSpan = maxNumOfColumns - numOfCells + 1; if (numOfColumnsToSpan < 1) { numOfColumnsToSpan = 1; @@ -417,7 +417,7 @@ public class FormRenderer { formStringRenderer.renderFieldTitle(writer, context, modelFormField); formStringRenderer.renderFormatHeaderRowCellClose(writer, context, modelForm, modelFormField); } - if (innerFormFields.size() > 0) { + if (!innerFormFields.isEmpty()) { // TODO: manage colspan formStringRenderer.renderFormatHeaderRowFormCellOpen(writer, context, modelForm); Iterator<ModelFormField> innerFormFieldsIt = innerFormFields.iterator(); @@ -522,7 +522,7 @@ public class FormRenderer { List<ModelFormField> innerDisplayHyperlinkFieldsEnd, List<ModelFormField> mainFieldList, int position, int numOfColumns) throws IOException { int numOfCells = innerDisplayHyperlinkFieldsBegin.size() + innerDisplayHyperlinkFieldsEnd.size() - + (innerFormFields.size() > 0 ? 1 : 0); + + (!innerFormFields.isEmpty() ? 1 : 0); int numOfColumnsToSpan = numOfColumns - numOfCells + 1; if (numOfColumnsToSpan < 1) { numOfColumnsToSpan = 1; @@ -581,7 +581,7 @@ public class FormRenderer { } // The form cell is rendered only if there is at least an input field - if (innerFormFields.size() > 0) { + if (!innerFormFields.isEmpty()) { // render the "form" cell formStringRenderer.renderFormatItemRowFormCellOpen(writer, localContext, modelForm); // TODO: colspan @@ -865,8 +865,8 @@ public class FormRenderer { // the fields in the three lists created in the preprocessing phase // are now rendered: this will create a visual representation // of one row (for the current position). - if (innerDisplayHyperlinkFieldsBegin.size() > 0 || innerFormFields.size() > 0 - || innerDisplayHyperlinkFieldsEnd.size() > 0) { + if (!innerDisplayHyperlinkFieldsBegin.isEmpty() || !innerFormFields.isEmpty() + || !innerDisplayHyperlinkFieldsEnd.isEmpty()) { this.renderItemRow(writer, localContext, formStringRenderer, formPerItem, hiddenIgnoredFieldList, innerDisplayHyperlinkFieldsBegin, innerFormFields, innerDisplayHyperlinkFieldsEnd, fieldListByPosition, currentPosition, numOfColumns); diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/ScreenRenderer.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/ScreenRenderer.java index 3b95245..a672a08 100644 --- a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/ScreenRenderer.java +++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/ScreenRenderer.java @@ -340,7 +340,7 @@ public class ScreenRenderer { } // if there was an error message, this is an error - context.put("isError", errorMessageList.size() > 0 ? Boolean.TRUE : Boolean.FALSE); + context.put("isError", !errorMessageList.isEmpty() ? Boolean.TRUE : Boolean.FALSE); // if a parameter was passed saying this is an error, it is an error if ("true".equals(parameterMap.get("isError"))) { context.put("isError", Boolean.TRUE); |
Free forum by Nabble | Edit this page |