svn commit: r1849846 - in /ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition: EntityComparisonOperator.java EntityConditionListBase.java EntityExpr.java EntityFieldValue.java EntityJoinOperator.java

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

svn commit: r1849846 - in /ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition: EntityComparisonOperator.java EntityConditionListBase.java EntityExpr.java EntityFieldValue.java EntityJoinOperator.java

adityasharma
Author: adityasharma
Date: Fri Dec 28 12:57:49 2018
New Revision: 1849846

URL: http://svn.apache.org/viewvc?rev=1849846&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/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityComparisonOperator.java
    ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionListBase.java
    ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityExpr.java
    ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityFieldValue.java
    ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityJoinOperator.java

Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityComparisonOperator.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityComparisonOperator.java?rev=1849846&r1=1849845&r2=1849846&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityComparisonOperator.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityComparisonOperator.java Fri Dec 28 12:57:49 2018
@@ -154,10 +154,8 @@ public abstract class EntityComparisonOp
             rightValue = rhs;
         }
 
-        if (leftValue == WILDCARD || rightValue == WILDCARD) {
-            return true;
-        }
-        return compare(UtilGenerics.<L>cast(leftValue), UtilGenerics.<R>cast(rightValue));
+        return leftValue == WILDCARD || rightValue == WILDCARD
+                || compare(UtilGenerics.<L>cast(leftValue), UtilGenerics.<R>cast(rightValue));
     }
 
     @Override

Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionListBase.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionListBase.java?rev=1849846&r1=1849845&r2=1849846&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionListBase.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionListBase.java Fri Dec 28 12:57:49 2018
@@ -94,8 +94,7 @@ public abstract class EntityConditionLis
         }
         EntityConditionListBase<?> other = UtilGenerics.cast(obj);
 
-        boolean isEqual = conditionList.equals(other.conditionList) && operator.equals(other.operator);
-        return isEqual;
+        return conditionList.equals(other.conditionList) && operator.equals(other.operator);
     }
 
     @Override

Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityExpr.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityExpr.java?rev=1849846&r1=1849845&r2=1849846&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityExpr.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityExpr.java Fri Dec 28 12:57:49 2018
@@ -264,10 +264,8 @@ public final class EntityExpr extends En
             return false;
         }
         EntityExpr other = (EntityExpr) obj;
-        boolean isEqual = equals(lhs, other.lhs) &&
-               equals(operator, other.operator) &&
-               equals(rhs, other.rhs);
-        return isEqual;
+        return equals(lhs, other.lhs) && equals(operator, other.operator)
+                && equals(rhs, other.rhs);
     }
 
     @Override

Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityFieldValue.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityFieldValue.java?rev=1849846&r1=1849845&r2=1849846&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityFieldValue.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityFieldValue.java Fri Dec 28 12:57:49 2018
@@ -111,16 +111,8 @@ public class EntityFieldValue extends En
             return false;
         }
         EntityFieldValue otherValue = (EntityFieldValue) obj;
-        if (!fieldName.equals(otherValue.fieldName)) {
-            return false;
-        }
-        if (UtilMisc.compare(this.entityAlias, otherValue.entityAlias) != 0) {
-            return false;
-        }
-        if (UtilMisc.compare(this.entityAliasStack, otherValue.entityAliasStack) != 0) {
-            return false;
-        }
-        return true;
+        return fieldName.equals(otherValue.fieldName) && !(UtilMisc.compare(this.entityAlias, otherValue.entityAlias) != 0)
+                && !(UtilMisc.compare(this.entityAliasStack, otherValue.entityAliasStack) != 0);
     }
 
     @Override

Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityJoinOperator.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityJoinOperator.java?rev=1849846&r1=1849845&r2=1849846&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityJoinOperator.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityJoinOperator.java Fri Dec 28 12:57:49 2018
@@ -116,10 +116,7 @@ public class EntityJoinOperator extends
 
     @Override
     public boolean entityMatches(GenericEntity entity, EntityCondition lhs, EntityCondition rhs) {
-        if (lhs.entityMatches(entity) == shortCircuitValue) {
-            return shortCircuitValue;
-        }
-        if (rhs.entityMatches(entity) == shortCircuitValue) {
+        if (lhs.entityMatches(entity) == shortCircuitValue || rhs.entityMatches(entity) == shortCircuitValue) {
             return shortCircuitValue;
         }
         return !shortCircuitValue;
@@ -135,10 +132,7 @@ public class EntityJoinOperator extends
 
     @Override
     public boolean mapMatches(Delegator delegator, Map<String, ? extends Object> map, EntityCondition lhs, EntityCondition rhs) {
-        if (lhs.mapMatches(delegator, map) == shortCircuitValue) {
-            return shortCircuitValue;
-        }
-        if (rhs.mapMatches(delegator, map) == shortCircuitValue) {
+        if (lhs.mapMatches(delegator, map) == shortCircuitValue || rhs.mapMatches(delegator, map) == shortCircuitValue) {
             return shortCircuitValue;
         }
         return !shortCircuitValue;