Author: adityasharma
Date: Fri Jan 18 05:08:59 2019 New Revision: 1851602 URL: http://svn.apache.org/viewvc?rev=1851602&view=rev Log: Improved: Refactor boolean returns from methods (OFBIZ-10725) Improved boolean returns with a single statement, replacing if blocks with the explicit boolean return. Modified: ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/survey/SurveyWrapper.java ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/LoopSubContentTransform.java ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReadHelper.java ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartItem.java ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryWorker.java ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/store/ProductStoreWorker.java ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/verify/VerifyPickSessionRow.java ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/weightPackage/WeightPackageSession.java Modified: ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/survey/SurveyWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/survey/SurveyWrapper.java?rev=1851602&r1=1851601&r2=1851602&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/survey/SurveyWrapper.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/survey/SurveyWrapper.java Fri Jan 18 05:08:59 2019 @@ -264,10 +264,7 @@ public class SurveyWrapper { } GenericValue survey = this.getSurvey(); - if (!"Y".equals(survey.getString("allowMultiple")) && !"Y".equals(survey.getString("allowUpdate"))) { - return false; - } - return true; + return !(!"Y".equals(survey.getString("allowMultiple")) && !"Y".equals(survey.getString("allowUpdate"))); } public boolean canRespond() { @@ -276,10 +273,7 @@ public class SurveyWrapper { return true; } GenericValue survey = this.getSurvey(); - if ("Y".equals(survey.getString("allowMultiple"))) { - return true; - } - return false; + return "Y".equals(survey.getString("allowMultiple")); } // returns a list of SurveyQuestions (in order by sequence number) for the current Survey Modified: ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/LoopSubContentTransform.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/LoopSubContentTransform.java?rev=1851602&r1=1851601&r2=1851602&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/LoopSubContentTransform.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/LoopSubContentTransform.java Fri Jan 18 05:08:59 2019 @@ -88,9 +88,7 @@ public class LoopSubContentTransform imp idx = 0; } int i = idx; - if (UtilValidate.isEmpty(lst)) { - return false; - } else if (i >= lst.size()) { + if (UtilValidate.isEmpty(lst) || i >= lst.size()) { return false; } GenericValue subContentDataResourceView = lst.get(i); Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReadHelper.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReadHelper.java?rev=1851602&r1=1851601&r2=1851602&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReadHelper.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReadHelper.java Fri Jan 18 05:08:59 2019 @@ -388,10 +388,7 @@ public class OrderReadHelper { } public boolean hasShippingAddress() { - if (UtilValidate.isNotEmpty(this.getShippingLocations())) { - return true; - } - return false; + return UtilValidate.isNotEmpty(this.getShippingLocations()); } public boolean hasPhysicalProductItems() throws GenericEntityException { Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java?rev=1851602&r1=1851601&r2=1851602&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java Fri Jan 18 05:08:59 2019 @@ -531,10 +531,8 @@ public class CheckOutEvents { return false; } GenericValue productStore = ProductStoreWorker.getProductStore(cart.getProductStoreId(), delegator); - if (productStore == null || productStore.get("explodeOrderItems") == null) { - return false; - } - return productStore.getBoolean("explodeOrderItems"); + return !(productStore == null || productStore.get("explodeOrderItems") == null) + && productStore.getBoolean("explodeOrderItems"); } public static String checkShipmentNeeded(HttpServletRequest request, HttpServletResponse response) { Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartItem.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartItem.java?rev=1851602&r1=1851601&r2=1851602&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartItem.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartItem.java Fri Jan 18 05:08:59 2019 @@ -1578,13 +1578,7 @@ public class ShoppingCartItem implements } public boolean isInItemGroup(String groupNumber) { - if (this.itemGroup == null) { - return false; - } - if (this.itemGroup.getGroupNumber().equals(groupNumber)) { - return true; - } - return false; + return !(this.itemGroup == null) && this.itemGroup.getGroupNumber().equals(groupNumber); } /** Returns the item type description. */ @@ -2489,13 +2483,9 @@ public class ShoppingCartItem implements return false; } - if ((this.orderItemAttributes == null && UtilValidate.isNotEmpty(orderItemAttributes)) || (UtilValidate.isNotEmpty(this.orderItemAttributes) && orderItemAttributes == null) || - (this.orderItemAttributes != null && orderItemAttributes != null && (this.orderItemAttributes.size() != orderItemAttributes.size() || !(this.orderItemAttributes.equals(orderItemAttributes))))) { // order item attribute unique - return false; - } - - return true; + return !((this.orderItemAttributes == null && UtilValidate.isNotEmpty(orderItemAttributes)) || (UtilValidate.isNotEmpty(this.orderItemAttributes) && orderItemAttributes == null) || + (this.orderItemAttributes != null && orderItemAttributes != null && (this.orderItemAttributes.size() != orderItemAttributes.size() || !(this.orderItemAttributes.equals(orderItemAttributes))))); } /** Gets the Product entity. If it is not already retreived gets it from the delegator */ Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryWorker.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryWorker.java?rev=1851602&r1=1851601&r2=1851602&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryWorker.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryWorker.java Fri Jan 18 05:08:59 2019 @@ -308,12 +308,7 @@ public final class CategoryWorker { public static boolean checkTrailItem(ServletRequest request, String category) { List<String> crumb = getTrail(request); - - if (crumb != null && crumb.contains(category)) { - return true; - } else { - return false; - } + return crumb != null && crumb.contains(category); } public static String lastTrailItem(ServletRequest request) { Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java?rev=1851602&r1=1851601&r2=1851602&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java Fri Jan 18 05:08:59 2019 @@ -748,10 +748,7 @@ public class ProductConfigWrapper implem public boolean isDefault() { ConfigOption defaultConfigOption = parentConfigItem.getDefault(); - if (this.equals(defaultConfigOption)) { - return true; - } - return false; + return this.equals(defaultConfigOption); } public boolean hasVirtualComponent () { Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/store/ProductStoreWorker.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/store/ProductStoreWorker.java?rev=1851602&r1=1851601&r2=1851602&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/store/ProductStoreWorker.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/store/ProductStoreWorker.java Fri Jan 18 05:08:59 2019 @@ -645,11 +645,7 @@ public final class ProductStoreWorker { availableOkay = wantAvailable == "Y".equals(invAvailResult.get("available")); } - if ((requiredOkay == null || requiredOkay) && (availableOkay == null || availableOkay)) { - return true; - } else { - return false; - } + return (requiredOkay == null || requiredOkay) && (availableOkay == null || availableOkay); } catch (GenericServiceException e) { String errMsg = "Fatal error calling inventory checking services: " + e.toString(); Debug.logError(e, errMsg, module); Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/verify/VerifyPickSessionRow.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/verify/VerifyPickSessionRow.java?rev=1851602&r1=1851601&r2=1851602&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/verify/VerifyPickSessionRow.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/verify/VerifyPickSessionRow.java Fri Jan 18 05:08:59 2019 @@ -116,11 +116,8 @@ public class VerifyPickSessionRow implem } public boolean isSameItem(VerifyPickSessionRow line) { - if (this.getInventoryItemId().equals(line.getInventoryItemId()) && this.getOrderItemSeqId().equals(line.getOrderItemSeqId()) - && this.getOrderId().equals(line.getOrderId()) && this.getShipGroupSeqId().equals(line.getShipGroupSeqId())) { - return true; - } - return false; + return this.getInventoryItemId().equals(line.getInventoryItemId()) && this.getOrderItemSeqId().equals(line.getOrderItemSeqId()) + && this.getOrderId().equals(line.getOrderId()) && this.getShipGroupSeqId().equals(line.getShipGroupSeqId()); } protected void issueItemToShipment(String shipmentId, String picklistBinId, GenericValue userLogin, BigDecimal quantity, LocalDispatcher dispatcher, Locale locale) throws GeneralException { Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/weightPackage/WeightPackageSession.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/weightPackage/WeightPackageSession.java?rev=1851602&r1=1851601&r2=1851602&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/weightPackage/WeightPackageSession.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/weightPackage/WeightPackageSession.java Fri Jan 18 05:08:59 2019 @@ -395,10 +395,7 @@ public class WeightPackageSession implem } else { diffInShipCostInPerc = (((actualShippingCost.subtract(estimatedShipCost)).divide(estimatedShipCost, 2, rounding)).multiply(new BigDecimal(100))).abs(); } - if (doEstimates.compareTo(diffInShipCostInPerc) == -1) { - return true; - } - return false; + return doEstimates.compareTo(diffInShipCostInPerc) == -1; } protected void createPackages(String orderId) throws GeneralException { |
Free forum by Nabble | Edit this page |