Improved : Remove all unnecessary boxing and unboxing in Java classes
(OFBIZ-10504) Thanks Taher, Jacques, Mathieu and Rishi for the review git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1837577 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
+1
-1
@@ -93,7 +93,7 @@ public final class ValidateMethodCondition extends MethodOperation implements Co
|
||||
Class<?> valClass = methodContext.getLoader().loadClass(className);
|
||||
Method valMethod = valClass.getMethod(methodName, paramTypes);
|
||||
Boolean resultBool = (Boolean) valMethod.invoke(null, params);
|
||||
return resultBool.booleanValue();
|
||||
return resultBool;
|
||||
} catch (Exception e) {
|
||||
throw new MiniLangRuntimeException(e, this);
|
||||
}
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ public final class TransactionCommit extends MethodOperation {
|
||||
boolean beganTransaction = false;
|
||||
Boolean beganTransactionBoolean = beganTransactionFma.get(methodContext.getEnvMap());
|
||||
if (beganTransactionBoolean != null) {
|
||||
beganTransaction = beganTransactionBoolean.booleanValue();
|
||||
beganTransaction = beganTransactionBoolean;
|
||||
}
|
||||
try {
|
||||
TransactionUtil.commit(beganTransaction);
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ public final class TransactionRollback extends MethodOperation {
|
||||
boolean beganTransaction = false;
|
||||
Boolean beganTransactionBoolean = beganTransactionFma.get(methodContext.getEnvMap());
|
||||
if (beganTransactionBoolean != null) {
|
||||
beganTransaction = beganTransactionBoolean.booleanValue();
|
||||
beganTransaction = beganTransactionBoolean;
|
||||
}
|
||||
try {
|
||||
TransactionUtil.rollback(beganTransaction, "Explicit rollback in simple-method [" + this.simpleMethod.getShortDescription() + "]", null);
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ public final class ToString extends MethodOperation {
|
||||
throw new MiniLangRuntimeException("Exception thrown while converting field to a string: " + e.getMessage(), this);
|
||||
}
|
||||
if (this.numericPadding != null) {
|
||||
value = StringUtil.padNumberString(value.toString(), this.numericPadding.intValue());
|
||||
value = StringUtil.padNumberString(value.toString(), this.numericPadding);
|
||||
}
|
||||
fieldFma.put(methodContext.getEnvMap(), value);
|
||||
}
|
||||
|
||||
+8
-8
@@ -129,7 +129,7 @@ public final class Calculate extends MethodOperation {
|
||||
String decimalScaleString = decimalScaleFse.expandString(methodContext.getEnvMap());
|
||||
int decimalScale = 2;
|
||||
if (!decimalScaleString.isEmpty()) {
|
||||
decimalScale = Integer.valueOf(decimalScaleString).intValue();
|
||||
decimalScale = Integer.valueOf(decimalScaleString);
|
||||
}
|
||||
BigDecimal resultValue = BigDecimal.ZERO.setScale(decimalScale, roundingMode);
|
||||
for (Calculate.SubCalc calcop : calcops) {
|
||||
@@ -139,18 +139,18 @@ public final class Calculate extends MethodOperation {
|
||||
Object resultObj = null;
|
||||
switch (type) {
|
||||
case TYPE_DOUBLE:
|
||||
resultObj = Double.valueOf(resultValue.doubleValue());
|
||||
resultObj = resultValue.doubleValue();
|
||||
break;
|
||||
case TYPE_FLOAT:
|
||||
resultObj = Float.valueOf(resultValue.floatValue());
|
||||
resultObj = resultValue.floatValue();
|
||||
break;
|
||||
case TYPE_LONG:
|
||||
resultValue = resultValue.setScale(0, roundingMode);
|
||||
resultObj = Long.valueOf(resultValue.longValue());
|
||||
resultObj = resultValue.longValue();
|
||||
break;
|
||||
case TYPE_INTEGER:
|
||||
resultValue = resultValue.setScale(0, roundingMode);
|
||||
resultObj = Integer.valueOf(resultValue.intValue());
|
||||
resultObj = resultValue.intValue();
|
||||
break;
|
||||
case TYPE_STRING:
|
||||
// run the decimal-formatting
|
||||
@@ -260,11 +260,11 @@ public final class Calculate extends MethodOperation {
|
||||
Object fieldObj = fieldFma.get(methodContext.getEnvMap());
|
||||
if (fieldObj != null) {
|
||||
if (fieldObj instanceof Double) {
|
||||
resultValue = new BigDecimal(((Double) fieldObj).doubleValue());
|
||||
resultValue = new BigDecimal((Double) fieldObj);
|
||||
} else if (fieldObj instanceof Long) {
|
||||
resultValue = BigDecimal.valueOf(((Long) fieldObj).longValue());
|
||||
resultValue = BigDecimal.valueOf((Long) fieldObj);
|
||||
} else if (fieldObj instanceof Float) {
|
||||
resultValue = new BigDecimal(((Float) fieldObj).floatValue());
|
||||
resultValue = new BigDecimal((Float) fieldObj);
|
||||
} else if (fieldObj instanceof Integer) {
|
||||
resultValue = BigDecimal.valueOf(((Integer) fieldObj).longValue());
|
||||
} else if (fieldObj instanceof String) {
|
||||
|
||||
@@ -60,7 +60,7 @@ public final class Log extends MethodOperation {
|
||||
MiniLangValidate.handleError("Invalid level attribute", simpleMethod, element);
|
||||
this.level = Debug.INFO;
|
||||
} else {
|
||||
this.level = levelInt.intValue();
|
||||
this.level = levelInt;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ public final class Trace extends MethodOperation {
|
||||
MiniLangValidate.handleError("Invalid level attribute", simpleMethod, element);
|
||||
this.level = Debug.INFO;
|
||||
} else {
|
||||
this.level = levelInt.intValue();
|
||||
this.level = levelInt;
|
||||
}
|
||||
methodOperations = Collections.unmodifiableList(SimpleMethod.readOperations(element, simpleMethod));
|
||||
}
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ public abstract class BaseCompare extends SimpleMapOperation {
|
||||
|
||||
public void doCompare(Object value1, Object value2, List<Object> messages, Locale locale, ClassLoader loader, boolean value2InlineConstant) {
|
||||
Boolean success = BaseCompare.doRealCompare(value1, value2, this.operator, this.type, this.format, messages, locale, loader, value2InlineConstant);
|
||||
if (success != null && success.booleanValue() == false) {
|
||||
if (success != null && success == false) {
|
||||
addMessage(messages, loader, locale);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -88,7 +88,7 @@ public class ValidateMethod extends SimpleMapOperation {
|
||||
Debug.logError("[ValidateMethod.exec] " + msg, module);
|
||||
return;
|
||||
}
|
||||
if (!resultBool.booleanValue()) {
|
||||
if (!resultBool) {
|
||||
addMessage(messages, loader, locale);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user