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:
Gil Portenseigne
2018-08-07 07:30:43 +00:00
parent 22d780cdae
commit ceea6ce791
176 changed files with 870 additions and 871 deletions
@@ -304,7 +304,7 @@ public class CommonServices {
public static Map<String, Object> makeALotOfVisits(DispatchContext dctx, Map<String, ?> context) {
Delegator delegator = dctx.getDelegator();
int count = ((Integer) context.get("count")).intValue();
int count = (Integer) context.get("count");
for (int i = 0; i < count; i++) {
GenericValue v = delegator.makeValue("Visit");
@@ -464,18 +464,18 @@ public class FindServices {
public static Map<String, Object> performFindList(DispatchContext dctx, Map<String, Object> context) {
Integer viewSize = (Integer) context.get("viewSize");
if (viewSize == null) {
viewSize = Integer.valueOf(20); // default
viewSize = 20; // default
}
context.put("viewSize", viewSize);
Integer viewIndex = (Integer) context.get("viewIndex");
if (viewIndex == null) {
viewIndex = Integer.valueOf(0); // default
viewIndex = 0; // default
}
context.put("viewIndex", viewIndex);
Map<String, Object> result = performFind(dctx,context);
int start = viewIndex.intValue() * viewSize.intValue();
int start = viewIndex * viewSize;
List<GenericValue> list = null;
Integer listSize = 0;
try (EntityListIterator it = (EntityListIterator) result.get("listIt")) {
@@ -64,8 +64,8 @@ public class FtpServices {
try {
Integer defaultTimeout = (Integer) context.get("defaultTimeout");
if (UtilValidate.isNotEmpty(defaultTimeout)) {
Debug.logInfo("[putFile] set default timeout to: " + defaultTimeout.intValue() + " milliseconds", module);
ftp.setDefaultTimeout(defaultTimeout.intValue());
Debug.logInfo("[putFile] set default timeout to: " + defaultTimeout + " milliseconds", module);
ftp.setDefaultTimeout(defaultTimeout);
}
Debug.logInfo("[putFile] connecting to: " + (String) context.get("hostname"), module);
ftp.connect((String) context.get("hostname"));
@@ -81,12 +81,12 @@ public class FtpServices {
errorList.add(UtilProperties.getMessage(resource, "CommonFtpLoginFailure", UtilMisc.toMap("username", username, "password", password), locale));
} else {
Boolean binaryTransfer = (Boolean) context.get("binaryTransfer");
boolean binary = (binaryTransfer == null) ? false : binaryTransfer.booleanValue();
boolean binary = (binaryTransfer == null) ? false : binaryTransfer;
if (binary) {
ftp.setFileType(FTP.BINARY_FILE_TYPE);
}
Boolean passiveMode = (Boolean) context.get("passiveMode");
boolean passive = (passiveMode == null) ? true : passiveMode.booleanValue();
boolean passive = (passiveMode == null) ? true : passiveMode;
if (passive) {
ftp.enterLocalPassiveMode();
}
@@ -149,8 +149,8 @@ public class FtpServices {
try {
Integer defaultTimeout = (Integer) context.get("defaultTimeout");
if (UtilValidate.isNotEmpty(defaultTimeout)) {
Debug.logInfo("[getFile] Set default timeout to: " + defaultTimeout.intValue() + " milliseconds", module);
ftp.setDefaultTimeout(defaultTimeout.intValue());
Debug.logInfo("[getFile] Set default timeout to: " + defaultTimeout + " milliseconds", module);
ftp.setDefaultTimeout(defaultTimeout);
}
ftp.connect((String) context.get("hostname"));
if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
@@ -162,12 +162,12 @@ public class FtpServices {
errorList.add(UtilProperties.getMessage(resource, "CommonFtpLoginFailure", UtilMisc.toMap("username", username, "password", password), locale));
} else {
Boolean binaryTransfer = (Boolean) context.get("binaryTransfer");
boolean binary = (binaryTransfer == null) ? false : binaryTransfer.booleanValue();
boolean binary = (binaryTransfer == null) ? false : binaryTransfer;
if (binary) {
ftp.setFileType(FTP.BINARY_FILE_TYPE);
}
Boolean passiveMode = (Boolean) context.get("passiveMode");
boolean passive = (passiveMode == null) ? false : passiveMode.booleanValue();
boolean passive = (passiveMode == null) ? false : passiveMode;
if (passive) {
ftp.enterLocalPassiveMode();
}
@@ -169,9 +169,9 @@ public final class KeywordSearchUtil {
// group by word, add up weight
Long curWeight = keywords.get(token);
if (curWeight == null) {
keywords.put(token, Long.valueOf(1));
keywords.put(token, 1L);
} else {
keywords.put(token, Long.valueOf(curWeight.longValue() + 1));
keywords.put(token, curWeight + 1);
}
}
}
@@ -60,7 +60,7 @@ public class LdapAuthenticationServices {
}
String dn = null;
Delegator delegator = ctx.getDelegator();
boolean isServiceAuth = context.get("isServiceAuth") != null && ((Boolean) context.get("isServiceAuth")).booleanValue();
boolean isServiceAuth = context.get("isServiceAuth") != null && (Boolean) context.get("isServiceAuth");
GenericValue userLogin = null;
try {
userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", username).cache(isServiceAuth).queryOne();
@@ -99,7 +99,7 @@ public class LoginServices {
boolean useEncryption = "true".equals(EntityUtilProperties.getPropertyValue("security", "password.encrypt", delegator));
// if isServiceAuth is not specified, default to not a service auth
boolean isServiceAuth = context.get("isServiceAuth") != null && ((Boolean) context.get("isServiceAuth")).booleanValue();
boolean isServiceAuth = context.get("isServiceAuth") != null && (Boolean) context.get("isServiceAuth");
String username = (String) context.get("login.username");
if (username == null) {
@@ -234,8 +234,8 @@ public class LoginServices {
// reset failed login count if necessary
Long currentFailedLogins = userLogin.getLong("successiveFailedLogins");
if (currentFailedLogins != null && currentFailedLogins.longValue() > 0) {
userLogin.set("successiveFailedLogins", Long.valueOf(0));
if (currentFailedLogins != null && currentFailedLogins > 0) {
userLogin.set("successiveFailedLogins", 0L);
} else if (!hasLoggedOut) {
// successful login & no logout flag, no need to change anything, so don't do the store
doStore = false;
@@ -273,9 +273,9 @@ public class LoginServices {
Long currentFailedLogins = userLogin.getLong("successiveFailedLogins");
if (currentFailedLogins == null) {
currentFailedLogins = Long.valueOf(1);
currentFailedLogins = 1L;
} else {
currentFailedLogins = Long.valueOf(currentFailedLogins.longValue() + 1);
currentFailedLogins = currentFailedLogins + 1;
}
userLogin.set("successiveFailedLogins", currentFailedLogins);
@@ -289,7 +289,7 @@ public class LoginServices {
Debug.logWarning("Could not parse max.failed.logins from security.properties, using default of 3", module);
}
if (maxFailedLogins > 0 && currentFailedLogins.longValue() >= maxFailedLogins) {
if (maxFailedLogins > 0 && currentFailedLogins >= maxFailedLogins) {
userLogin.set("enabled", "N");
userLogin.set("disabledDateTime", UtilDateTime.nowTimestamp());
}
@@ -439,7 +439,7 @@ public class LoginServices {
public static void createUserLoginPasswordHistory(Delegator delegator,String userLoginId, String currentPassword) throws GenericEntityException{
int passwordChangeHistoryLimit = 0;
try {
passwordChangeHistoryLimit = EntityUtilProperties.getPropertyAsInteger("security", "password.change.history.limit", 0).intValue();
passwordChangeHistoryLimit = EntityUtilProperties.getPropertyAsInteger("security", "password.change.history.limit", 0);
} catch (NumberFormatException nfe) {
//No valid value is found so don't bother to save any password history
passwordChangeHistoryLimit = 0;
@@ -946,7 +946,7 @@ public class LoginServices {
int passwordChangeHistoryLimit = 0;
try {
passwordChangeHistoryLimit = EntityUtilProperties.getPropertyAsInteger("security", "password.change.history.limit", 0).intValue();
passwordChangeHistoryLimit = EntityUtilProperties.getPropertyAsInteger("security", "password.change.history.limit", 0);
} catch (NumberFormatException nfe) {
//No valid value is found so don't bother to save any password history
passwordChangeHistoryLimit = 0;
@@ -979,7 +979,7 @@ public class LoginServices {
int minPasswordLength = 0;
try {
minPasswordLength = EntityUtilProperties.getPropertyAsInteger("security", "password.length.min", 0).intValue();
minPasswordLength = EntityUtilProperties.getPropertyAsInteger("security", "password.length.min", 0);
} catch (NumberFormatException nfe) {
minPasswordLength = 0;
}
@@ -111,7 +111,7 @@ public class QRCodeEvents {
if (UtilValidate.isNotEmpty(encoding)) {
context.put("encoding", encoding);
}
if (UtilValidate.isNotEmpty(verifyOutput) && verifyOutput.booleanValue()) {
if (UtilValidate.isNotEmpty(verifyOutput) && verifyOutput) {
context.put("verifyOutput", verifyOutput);
}
if (UtilValidate.isNotEmpty(logoImageMaxWidth)) {
@@ -124,13 +124,13 @@ public class QRCodeServices {
if (width == null) {
width = Integer.parseInt(QRCODE_DEFAULT_WIDTH);
}
if (width.intValue() < MIN_SIZE || width.intValue() > MAX_SIZE) {
if (width < MIN_SIZE || width > MAX_SIZE) {
return ServiceUtil.returnError(UtilProperties.getMessage("QRCodeUiLabels", "SizeOutOfBorderError", new Object[] {"width", String.valueOf(width), String.valueOf(MIN_SIZE), String.valueOf(MAX_SIZE)}, locale));
}
if (height == null) {
height = Integer.parseInt(QRCODE_DEFAULT_HEIGHT);
}
if (height.intValue() < MIN_SIZE || height.intValue() > MAX_SIZE) {
if (height < MIN_SIZE || height > MAX_SIZE) {
return ServiceUtil.returnError(UtilProperties.getMessage("QRCodeUiLabels", "SizeOutOfBorderError",
new Object[] { "height", String.valueOf(height), String.valueOf(MIN_SIZE), String.valueOf(MAX_SIZE) }, locale));
}
@@ -165,7 +165,7 @@ public class QRCodeServices {
BufferedImage newBufferedImage = null;
if (UtilValidate.isNotEmpty(logoBufferedImage)) {
if (UtilValidate.isNotEmpty(logoImageMaxWidth) && UtilValidate.isNotEmpty(logoImageMaxHeight) && (logoBufferedImage.getWidth() > logoImageMaxWidth.intValue() || logoBufferedImage.getHeight() > logoImageMaxHeight.intValue())) {
if (UtilValidate.isNotEmpty(logoImageMaxWidth) && UtilValidate.isNotEmpty(logoImageMaxHeight) && (logoBufferedImage.getWidth() > logoImageMaxWidth || logoBufferedImage.getHeight() > logoImageMaxHeight)) {
Map<String, String> typeMap = new HashMap<>();
typeMap.put("width", logoImageMaxWidth.toString());
typeMap.put("height", logoImageMaxHeight.toString());
@@ -181,7 +181,7 @@ public class QRCodeServices {
graphics.dispose();
}
if (UtilValidate.isNotEmpty(verifyOutput) && verifyOutput.booleanValue()) {
if (UtilValidate.isNotEmpty(verifyOutput) && verifyOutput) {
Decoder decoder = new Decoder();
Map<DecodeHintType, Object> decodeHints = new EnumMap<>(DecodeHintType.class);
decodeHints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);