[ofbiz-framework] branch trunk updated: Improved: Replace Map.get() with Map.getOrDefault() method.(OFBIZ-11832)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[ofbiz-framework] branch trunk updated: Improved: Replace Map.get() with Map.getOrDefault() method.(OFBIZ-11832)

Pawan Verma-2
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 30732dd  Improved: Replace Map.get() with Map.getOrDefault() method.(OFBIZ-11832)
30732dd is described below

commit 30732dd57b4d54a32a65eab487fdd7de796360ee
Author: Pawan Verma <[hidden email]>
AuthorDate: Mon Jun 22 21:26:18 2020 +0530

    Improved: Replace Map.get() with Map.getOrDefault() method.(OFBIZ-11832)
   
    Set checkstyleMain.maxErrors to 26682 (-2)
---
 .../java/org/apache/ofbiz/accounting/tax/TaxAuthorityServices.java | 2 +-
 .../accounting/thirdparty/authorizedotnet/AIMRespPositions.java    | 6 +-----
 .../accounting/thirdparty/authorizedotnet/CPRespPositions.java     | 6 +-----
 .../main/java/org/apache/ofbiz/webapp/control/RequestHandler.java  | 7 ++-----
 4 files changed, 5 insertions(+), 16 deletions(-)

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 f5d88ba..cbc0ec9 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
@@ -266,7 +266,7 @@ public class TaxAuthorityServices {
             itemAdjustments.add(taxList);
             
             //Calculates the TotalPrices for each Product in the Order
-            BigDecimal currentTotalPrice =  productWeight.containsKey(product) ? productWeight.get(product) : BigDecimal.ZERO;
+            BigDecimal currentTotalPrice = productWeight.getOrDefault(product, BigDecimal.ZERO);
             currentTotalPrice = currentTotalPrice.add(itemAmount);
             productWeight.put(product, currentTotalPrice);
         }
diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/authorizedotnet/AIMRespPositions.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/authorizedotnet/AIMRespPositions.java
index 4830033..96b4cad 100644
--- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/authorizedotnet/AIMRespPositions.java
+++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/authorizedotnet/AIMRespPositions.java
@@ -39,11 +39,7 @@ public class AIMRespPositions extends AuthorizeResponse.RespPositions {
     
     @Override
     public int getPosition(String name) {
-        if (positions.containsKey(name)) {
-            return positions.get(name);
-        } else {
-            return -1;
-        }              
+        return positions.getOrDefault(name, -1);
     }
     
     @Override
diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/authorizedotnet/CPRespPositions.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/authorizedotnet/CPRespPositions.java
index acea6f2..c9e6b74 100644
--- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/authorizedotnet/CPRespPositions.java
+++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/authorizedotnet/CPRespPositions.java
@@ -39,11 +39,7 @@ public class CPRespPositions extends AuthorizeResponse.RespPositions {
 
     @Override
     public int getPosition(String name) {
-        if (positions.containsKey(name)) {
-            return positions.get(name);
-        } else {
-            return -1;
-        }
+        return positions.getOrDefault(name, -1);
     }
     
     @Override
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 72ee26d..dfba382 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
@@ -933,11 +933,8 @@ public class RequestHandler {
         // add in the attributes as well so everything needed for the rendering context will be in place if/when we get back to this view
         paramMap.putAll(UtilHttp.getAttributeMap(req));
         UtilMisc.makeMapSerializable(paramMap);
-        if (paramMap.containsKey("_LAST_VIEW_NAME_")) { // Used by lookups to keep the real view (request)
-            req.getSession().setAttribute("_LAST_VIEW_NAME_", paramMap.get("_LAST_VIEW_NAME_"));
-        } else {
-            req.getSession().setAttribute("_LAST_VIEW_NAME_", view);
-        }
+        // Used by lookups to keep the real view (request)
+        req.getSession().setAttribute("_LAST_VIEW_NAME_", paramMap.getOrDefault("_LAST_VIEW_NAME_", view));
         req.getSession().setAttribute("_LAST_VIEW_PARAMS_", paramMap);
 
         if ("SAVED".equals(saveName)) {