Skip to content

Commit

Permalink
Improved : Remove all unnecessary boxing and unboxing in Java classes
Browse files Browse the repository at this point in the history
(OFBIZ-10504)

Thanks Taher, Jacques, Mathieu and Rishi for the review

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-plugins/trunk@1837578 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
gilPts committed Aug 7, 2018
1 parent 5550099 commit 7c294b1
Show file tree
Hide file tree
Showing 17 changed files with 48 additions and 48 deletions.
Expand Up @@ -55,7 +55,7 @@ public static Map<String, Object> addPartFixedAssetMaint(DispatchContext ctx, Ma
String productId = (String)context.get("productId");
String facilityId = (String)context.get("facilityId");
Double quantity = (Double)context.get("quantity");
double requestedQty = quantity.doubleValue();
double requestedQty = quantity;

try {
GenericValue product = ProductWorker.findProduct(delegator, productId);
Expand Down Expand Up @@ -87,13 +87,13 @@ public static Map<String, Object> addPartFixedAssetMaint(DispatchContext ctx, Ma
while (requestedQty > 0 && itr.hasNext()) {
GenericValue inventoryItem = itr.next();
String inventoryItemId = inventoryItem.getString("inventoryItemId");
atp = inventoryItem.getDouble("availableToPromiseTotal").doubleValue();
atp = inventoryItem.getDouble("availableToPromiseTotal");
findCurrInventoryParams = UtilMisc.toMap("inventoryItemId", inventoryItemId);
Double issueQuantity = null;
if (requestedQty > atp) {
issueQuantity = new Double(atp);
issueQuantity = atp;
} else {
issueQuantity = new Double(requestedQty);
issueQuantity = requestedQty;
}
Map<String, Object> itemIssuanceCtx = new HashMap<String, Object>();
itemIssuanceCtx.put("userLogin", userLogin);
Expand All @@ -106,7 +106,7 @@ public static Map<String, Object> addPartFixedAssetMaint(DispatchContext ctx, Ma
if (ServiceUtil.isError(result)) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "AssetMaintProblemCallingService", locale), null, null, result);
}
requestedQty = requestedQty - issueQuantity.doubleValue();
requestedQty = requestedQty - issueQuantity;
}
} catch (GenericEntityException e) {
Debug.logError("Problem in retriving data from database", module);
Expand Down
2 changes: 1 addition & 1 deletion ebay/src/main/java/org/apache/ofbiz/ebay/EbayHelper.java
Expand Up @@ -287,7 +287,7 @@ public static GenericValue makeOrderAdjustment(Delegator delegator, String order
"orderItemSeqId", orderItemSeqId, "shipGroupSeqId", shipGroupSeqId, "amount",
new BigDecimal(amount));
if (sourcePercentage != 0) {
inputMap.put("sourcePercentage", new Double(sourcePercentage));
inputMap.put("sourcePercentage", sourcePercentage);
}
orderAdjustment = delegator.makeValue("OrderAdjustment", inputMap);
} catch (Exception e) {
Expand Down
14 changes: 7 additions & 7 deletions ebay/src/main/java/org/apache/ofbiz/ebay/EbayOrderServices.java
Expand Up @@ -743,13 +743,13 @@ private static List<Map<String, Object>> readGetSellerTransactionResponse(String
double shippingSurcharge = 0;

if (UtilValidate.isNotEmpty(incuranceCost)) {
shippingInsuranceCost = new Double(incuranceCost).doubleValue();
shippingInsuranceCost = new Double(incuranceCost);
}
if (UtilValidate.isNotEmpty(additionalCost)) {
shippingServiceAdditionalCost = new Double(additionalCost).doubleValue();
shippingServiceAdditionalCost = new Double(additionalCost);
}
if (UtilValidate.isNotEmpty(surchargeCost)) {
shippingSurcharge = new Double(surchargeCost).doubleValue();
shippingSurcharge = new Double(surchargeCost);
}
double shippingTotalAdditionalCost = shippingInsuranceCost + shippingServiceAdditionalCost + shippingSurcharge;
String totalAdditionalCost = new Double(shippingTotalAdditionalCost).toString();
Expand Down Expand Up @@ -1063,7 +1063,7 @@ private static Map<String, Object> createShoppingCart(Delegator delegator, Local

String shippingCost = (String) shippingServiceSelectedCtx.get("shippingServiceCost");
if (UtilValidate.isNotEmpty(shippingCost)) {
double shippingAmount = new Double(shippingCost).doubleValue();
double shippingAmount = new Double(shippingCost);
if (shippingAmount > 0) {
GenericValue shippingAdjustment = EbayHelper.makeOrderAdjustment(delegator, "SHIPPING_CHARGES", cart.getOrderId(), null, null, shippingAmount, 0.0);
if (shippingAdjustment != null) {
Expand All @@ -1074,7 +1074,7 @@ private static Map<String, Object> createShoppingCart(Delegator delegator, Local
// Apply additional shipping costs as order adjustment
String shippingTotalAdditionalCost = (String) shippingServiceSelectedCtx.get("shippingTotalAdditionalCost");
if (UtilValidate.isNotEmpty(shippingTotalAdditionalCost)) {
double shippingAdditionalCost = new Double(shippingTotalAdditionalCost).doubleValue();
double shippingAdditionalCost = new Double(shippingTotalAdditionalCost);
if (shippingAdditionalCost > 0) {
GenericValue shippingAdjustment = EbayHelper.makeOrderAdjustment(delegator, "MISCELLANEOUS_CHARGE", cart.getOrderId(), null, null, shippingAdditionalCost, 0.0);
if (shippingAdjustment != null) {
Expand All @@ -1087,11 +1087,11 @@ private static Map<String, Object> createShoppingCart(Delegator delegator, Local
String salesTaxAmount = (String) shippingDetailsCtx.get("salesTaxAmount");
String salesTaxPercent = (String) shippingDetailsCtx.get("salesTaxPercent");
if (UtilValidate.isNotEmpty(salesTaxAmount)) {
double salesTaxAmountTotal = new Double(salesTaxAmount).doubleValue();
double salesTaxAmountTotal = new Double(salesTaxAmount);
if (salesTaxAmountTotal > 0) {
double salesPercent = 0.0;
if (UtilValidate.isNotEmpty(salesTaxPercent)) {
salesPercent = new Double(salesTaxPercent).doubleValue();
salesPercent = new Double(salesTaxPercent);
}
GenericValue salesTaxAdjustment = EbayHelper.makeOrderAdjustment(delegator, "SALES_TAX", cart.getOrderId(), null, null, salesTaxAmountTotal, salesPercent);
if (salesTaxAdjustment != null) {
Expand Down
Expand Up @@ -545,15 +545,15 @@ private static List<Map<String, Object>> readResponseFromEbay(String msg, Locale
double shippingSurcharge = 0;

if (UtilValidate.isNotEmpty(incuranceCost)) {
shippingInsuranceCost = new Double(incuranceCost).doubleValue();
shippingInsuranceCost = new Double(incuranceCost);
}

if (UtilValidate.isNotEmpty(additionalCost)) {
shippingServiceAdditionalCost = new Double(additionalCost).doubleValue();
shippingServiceAdditionalCost = new Double(additionalCost);
}

if (UtilValidate.isNotEmpty(surchargeCost)) {
shippingSurcharge = new Double(surchargeCost).doubleValue();
shippingSurcharge = new Double(surchargeCost);
}

double shippingTotalAdditionalCost = shippingInsuranceCost + shippingServiceAdditionalCost + shippingSurcharge;
Expand Down Expand Up @@ -681,7 +681,7 @@ private static Map<String, Object> createShoppingCart(Delegator delegator, Local
// Apply shipping costs as order adjustment
String shippingCost = (String) parameters.get("shippingServiceCost");
if (UtilValidate.isNotEmpty(shippingCost)) {
double shippingAmount = new Double(shippingCost).doubleValue();
double shippingAmount = new Double(shippingCost);
if (shippingAmount > 0) {
GenericValue shippingAdjustment = EbayHelper.makeOrderAdjustment(delegator, "SHIPPING_CHARGES", cart.getOrderId(), null, null, shippingAmount, 0.0);
if (shippingAdjustment != null) {
Expand All @@ -693,7 +693,7 @@ private static Map<String, Object> createShoppingCart(Delegator delegator, Local
// Apply additional shipping costs as order adjustment
String shippingTotalAdditionalCost = (String) parameters.get("shippingTotalAdditionalCost");
if (UtilValidate.isNotEmpty(shippingTotalAdditionalCost)) {
double shippingAdditionalCost = new Double(shippingTotalAdditionalCost).doubleValue();
double shippingAdditionalCost = new Double(shippingTotalAdditionalCost);
if (shippingAdditionalCost > 0) {
GenericValue shippingAdjustment = EbayHelper.makeOrderAdjustment(delegator, "MISCELLANEOUS_CHARGE", cart.getOrderId(), null, null, shippingAdditionalCost, 0.0);
if (shippingAdjustment != null) {
Expand All @@ -706,11 +706,11 @@ private static Map<String, Object> createShoppingCart(Delegator delegator, Local
String salesTaxAmount = (String) parameters.get("salesTaxAmount");
String salesTaxPercent = (String) parameters.get("salesTaxPercent");
if (UtilValidate.isNotEmpty(salesTaxAmount)) {
double salesTaxAmountTotal = new Double(salesTaxAmount).doubleValue();
double salesTaxAmountTotal = new Double(salesTaxAmount);
if (salesTaxAmountTotal > 0) {
double salesPercent = 0.0;
if (UtilValidate.isNotEmpty(salesTaxPercent)) {
salesPercent = new Double(salesTaxPercent).doubleValue();
salesPercent = new Double(salesTaxPercent);
}
GenericValue salesTaxAdjustment = EbayHelper.makeOrderAdjustment(delegator, "SALES_TAX", cart.getOrderId(), null, null, salesTaxAmountTotal, salesPercent);
if (salesTaxAdjustment != null) {
Expand Down
Expand Up @@ -525,7 +525,7 @@ public static Map<String, Object> getEbayCategories(DispatchContext dctx, Map<St
categoryParent = params[1];
levelLimit = params[2];
Integer level = Integer.valueOf(levelLimit);
levelLimit = (level.intValue() + 1) + "";
levelLimit = (level + 1) + "";
}
}

Expand Down
Expand Up @@ -187,7 +187,7 @@ public static Map<String, Object> EbayStoreCreateTransactionShoppingCart(Dispatc

String shippingTotalAdditionalCost = context.get("shippingTotalAdditionalCost").toString();
if (UtilValidate.isNotEmpty(shippingTotalAdditionalCost)) {
double shippingAdditionalCost = new Double(shippingTotalAdditionalCost).doubleValue();
double shippingAdditionalCost = new Double(shippingTotalAdditionalCost);
if (shippingAdditionalCost > 0) {
GenericValue shippingAdjustment = EbayHelper.makeOrderAdjustment(delegator, "MISCELLANEOUS_CHARGE", cart.getOrderId(), null, null, shippingAdditionalCost, 0.0);
if (shippingAdjustment != null) {
Expand All @@ -199,11 +199,11 @@ public static Map<String, Object> EbayStoreCreateTransactionShoppingCart(Dispatc
String salesTaxAmount = context.get("salesTaxAmount").toString();
String salesTaxPercent = context.get("salesTaxPercent").toString();
if (UtilValidate.isNotEmpty(salesTaxAmount)) {
double salesTaxAmountTotal = new Double(salesTaxAmount).doubleValue();
double salesTaxAmountTotal = new Double(salesTaxAmount);
if (salesTaxAmountTotal > 0) {
double salesPercent = 0.0;
if (UtilValidate.isNotEmpty(salesTaxPercent)) {
salesPercent = new Double(salesTaxPercent).doubleValue();
salesPercent = new Double(salesTaxPercent);
}
GenericValue salesTaxAdjustment = EbayHelper.makeOrderAdjustment(delegator, "SALES_TAX", cart.getOrderId(), null, null, salesTaxAmountTotal, salesPercent);
if (salesTaxAdjustment != null) {
Expand Down Expand Up @@ -404,7 +404,7 @@ public static Map<String, Object> EbayStoreCreateOrderShoppingCart(DispatchConte
if (salesTaxAmount.doubleValue() > 0) {
double salesPercent = 0.0;
if (UtilValidate.isNotEmpty(shippingDetailsCtx.get("salesTaxPercent"))) {
salesPercent = new Double(shippingDetailsCtx.get("salesTaxPercent").toString()).doubleValue();
salesPercent = new Double(shippingDetailsCtx.get("salesTaxPercent").toString());
}
GenericValue salesTaxAdjustment = EbayHelper.makeOrderAdjustment(delegator, "SALES_TAX", cart.getOrderId(), null, null, salesTaxAmount.doubleValue(), salesPercent);
if (salesTaxAdjustment != null) {
Expand Down
Expand Up @@ -183,7 +183,7 @@ public Document prepareDocument(Delegator delegator) {
int weight = 1;
try {
// this is defaulting to a weight of 1 because you specified you wanted to index this type
weight = EntityUtilProperties.getPropertyAsInteger("prodsearch", "index.weight.ProductContent." + productContentTypeId, 1).intValue();
weight = EntityUtilProperties.getPropertyAsInteger("prodsearch", "index.weight.ProductContent." + productContentTypeId, 1);
} catch (Exception e) {
Debug.logWarning("Could not parse weight number: " + e.toString(), module);
}
Expand Down
Expand Up @@ -285,7 +285,7 @@ private static String checkLoginGitHubUser(HttpServletRequest request, Map<Strin
String userLoginId = authn.createUser(userInfo);
userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", userLoginId).queryOne();
}
String autoPassword = RandomStringUtils.randomAlphanumeric(EntityUtilProperties.getPropertyAsInteger("security", "password.length.min", 5).intValue());
String autoPassword = RandomStringUtils.randomAlphanumeric(EntityUtilProperties.getPropertyAsInteger("security", "password.length.min", 5));
boolean useEncryption = "true".equals(UtilProperties.getPropertyValue("security", "password.encrypt"));
userLogin.set("currentPassword", useEncryption ? HashCrypt.digestHash(LoginServices.getHashType(), null, autoPassword) : autoPassword);
userLogin.store();
Expand Down
Expand Up @@ -292,7 +292,7 @@ private static String checkLoginLinkedInUser(HttpServletRequest request, Documen
String userLoginId = authn.createUser(userInfo);
userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", userLoginId).queryOne();
}
String autoPassword = RandomStringUtils.randomAlphanumeric(EntityUtilProperties.getPropertyAsInteger("security", "password.length.min", 5).intValue());
String autoPassword = RandomStringUtils.randomAlphanumeric(EntityUtilProperties.getPropertyAsInteger("security", "password.length.min", 5));
boolean useEncryption = "true".equals(UtilProperties.getPropertyValue("security", "password.encrypt"));
userLogin.set("currentPassword", useEncryption ? HashCrypt.digestHash(LoginServices.getHashType(), null, autoPassword) : autoPassword);
userLogin.store();
Expand Down
Expand Up @@ -939,7 +939,7 @@ public String dialogButtonsContinue(String okAttrs, String cancelAttrs) {
* @return the button row
*/
public String dialogButtonsOkCancel(HttpServletRequest request, String okAttrs, String cancelAttrs) {
if (Boolean.valueOf(getParamThreadHasNext(request)).booleanValue()
if (Boolean.valueOf(getParamThreadHasNext(request))
&& ReportStringUtil.isNotEmpty(getParamReportContinueKey())) {
return dialogButtons(new int[] {BUTTON_OK, BUTTON_CANCEL}, new String[] {
okAttrs,
Expand All @@ -964,7 +964,7 @@ public String dialogButtonsOkCancelDownload(HttpServletRequest request, String o
} else {
downloadAttrs += " ";
}
if (Boolean.valueOf(getParamThreadHasNext(request)).booleanValue()
if (Boolean.valueOf(getParamThreadHasNext(request))
&& ReportStringUtil.isNotEmpty(getParamReportContinueKey())) {
return dialogButtons(new int[] {BUTTON_OK, BUTTON_CANCEL, BUTTON_DOWNLOAD}, new String[] {
okAttrs,
Expand Down
Expand Up @@ -228,7 +228,7 @@ public static String decodeHtmlEntities(String input, String encoding) {
while (matcher.find()) {
String entity = matcher.group();
String value = entity.substring(2, entity.length() - 1);
int c = Integer.valueOf(value).intValue();
int c = Integer.valueOf(value);
if (c < 128) {
// first 128 chars are contained in almost every charset
entity = new String(new char[] {(char)c});
Expand Down

0 comments on commit 7c294b1

Please sign in to comment.