Improved: Refactor boolean returns from methods

(OFBIZ-10725)
Improved boolean returns with a single statement, replacing if blocks with the explicit boolean return.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1849846 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Aditya Sharma
2018-12-28 12:57:49 +00:00
parent 98814e5c03
commit d0eff38e8d
5 changed files with 9 additions and 28 deletions
@@ -154,10 +154,8 @@ public abstract class EntityComparisonOperator<L, R> extends EntityOperator<L, R
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
@@ -94,8 +94,7 @@ public abstract class EntityConditionListBase<T extends EntityCondition> extends
}
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
@@ -264,10 +264,8 @@ public final class EntityExpr extends EntityCondition {
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
@@ -111,16 +111,8 @@ public class EntityFieldValue extends EntityConditionValue {
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
@@ -116,10 +116,7 @@ public class EntityJoinOperator extends EntityOperator<EntityCondition, EntityCo
@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 EntityOperator<EntityCondition, EntityCo
@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;