Author: adityasharma
Date: Wed Jan 16 10:07:05 2019
New Revision: 1851425
URL: http://svn.apache.org/viewvc?rev=1851425&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/accounting/src/main/java/org/apache/ofbiz/accounting/payment/GiftCertificateServices.java
ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/util/UtilAccounting.java
ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentSearch.java
Modified:
ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/GiftCertificateServices.java
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/GiftCertificateServices.java?rev=1851425&r1=1851424&r2=1851425&view=diff
==============================================================================
---
ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/GiftCertificateServices.java
(original)
+++
ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/GiftCertificateServices.java
Wed Jan 16 10:07:05 2019
@@ -1450,10 +1450,7 @@ public class GiftCertificateServices {
private static boolean checkNumberInDatabase(Delegator delegator, String
number) throws GenericEntityException {
GenericValue finAccount =
EntityQuery.use(delegator).from("FinAccount").where("finAccountId",
number).queryOne();
- if (finAccount == null) {
- return true;
- }
- return false;
+ return finAccount == null;
}
private static boolean checkCardNumber(String number) {
Modified:
ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/util/UtilAccounting.java
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/util/UtilAccounting.java?rev=1851425&r1=1851424&r2=1851425&view=diff
==============================================================================
---
ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/util/UtilAccounting.java
(original)
+++
ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/util/UtilAccounting.java
Wed Jan 16 10:07:05 2019
@@ -117,15 +117,10 @@ public final class UtilAccounting {
// first check the parentTypeId against inputTypeId
String parentTypeId = paymentType.getString("parentTypeId");
- if (parentTypeId == null) {
- return false;
- }
- if (parentTypeId.equals(inputTypeId)) {
- return true;
- }
- // otherwise, we have to go to the grandparent (recurse)
- return
isPaymentTypeRecurse(paymentType.getRelatedOne("ParentPaymentType", false),
inputTypeId);
+ // isPaymentTypeRecurse => otherwise, we have to go to the grandparent
(recurse)
+ return !(parentTypeId == null) &&
+ (parentTypeId.equals(inputTypeId) ||
isPaymentTypeRecurse(paymentType.getRelatedOne("ParentPaymentType", false),
inputTypeId));
}
@@ -144,12 +139,9 @@ public final class UtilAccounting {
}
String paymentTypeId = paymentType.getString("paymentTypeId");
- if (inputTypeId.equals(paymentTypeId)) {
- return true;
- }
// recurse up tree
- return isPaymentTypeRecurse(paymentType, inputTypeId);
+ return inputTypeId.equals(paymentTypeId) ||
isPaymentTypeRecurse(paymentType, inputTypeId);
}
@@ -179,15 +171,10 @@ public final class UtilAccounting {
// check parentClassId against inputClassId
String parentClassId = glAccountClass.getString("parentClassId");
- if (parentClassId == null) {
- return false;
- }
- if (parentClassId.equals(parentGlAccountClassId)) {
- return true;
- }
// otherwise, we have to go to the grandparent (recurse)
- return
isAccountClassClass(glAccountClass.getRelatedOne("ParentGlAccountClass", true),
parentGlAccountClassId);
+ return !(parentClassId == null) &&
+ (parentClassId.equals(parentGlAccountClassId) ||
isAccountClassClass(glAccountClass.getRelatedOne("ParentGlAccountClass", true),
parentGlAccountClassId));
}
/**
@@ -248,15 +235,10 @@ public final class UtilAccounting {
// first check the invoiceTypeId and parentTypeId against inputTypeId
String invoiceTypeId = invoiceType.getString("invoiceTypeId");
String parentTypeId = invoiceType.getString("parentTypeId");
- if (parentTypeId == null || invoiceTypeId.equals(parentTypeId)) {
- return false;
- }
- if (parentTypeId.equals(inputTypeId)) {
- return true;
- }
// otherwise, we have to go to the grandparent (recurse)
- return
isInvoiceTypeRecurse(invoiceType.getRelatedOne("ParentInvoiceType", false),
inputTypeId);
+ return !(parentTypeId == null || invoiceTypeId.equals(parentTypeId)) &&
+ (parentTypeId.equals(inputTypeId) ||
isInvoiceTypeRecurse(invoiceType.getRelatedOne("ParentInvoiceType", false),
inputTypeId));
}
/**
@@ -274,12 +256,10 @@ public final class UtilAccounting {
}
String invoiceTypeId = invoiceType.getString("invoiceTypeId");
- if (inputTypeId.equals(invoiceTypeId)) {
- return true;
- }
// recurse up tree
- return isInvoiceTypeRecurse(invoiceType, inputTypeId);
+ return inputTypeId.equals(invoiceTypeId)
+ || isInvoiceTypeRecurse(invoiceType, inputTypeId);
}
Modified:
ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentSearch.java
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentSearch.java?rev=1851425&r1=1851424&r2=1851425&view=diff
==============================================================================
---
ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentSearch.java
(original)
+++
ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentSearch.java
Wed Jan 16 10:07:05 2019
@@ -697,16 +697,10 @@ public class ContentSearch {
ContentSearchConstraint psc = (ContentSearchConstraint) obj;
if (psc instanceof KeywordConstraint) {
KeywordConstraint that = (KeywordConstraint) psc;
- if (this.anyPrefix != that.anyPrefix) {
- return false;
- }
- if (this.anySuffix != that.anySuffix) {
- return false;
- }
- if (this.isAnd != that.isAnd) {
- return false;
- }
- if (this.removeStems != that.removeStems) {
+ if (this.anyPrefix != that.anyPrefix
+ || this.anySuffix != that.anySuffix
+ || this.isAnd != that.isAnd
+ || this.removeStems != that.removeStems) {
return false;
}
if (this.keywordsString == null) {