Author: mbrohl
Date: Sun Dec 17 10:37:49 2017 New Revision: 1818469 URL: http://svn.apache.org/viewvc?rev=1818469&view=rev Log: Improved: General refactoring and code improvements, package org.apache.ofbiz.entity.condition. (OFBIZ-9956) Thanks Dennis Balkir for reporting and providing the patches. Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityClause.java 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/EntityCondition.java ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionBase.java ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionFunction.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/EntityConditionSubSelect.java ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityDateFilterCondition.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/EntityFunction.java ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityJoinOperator.java ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityOperator.java ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityWhereString.java ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByItem.java ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByList.java Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityClause.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityClause.java?rev=1818469&r1=1818468&r2=1818469&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityClause.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityClause.java Sun Dec 17 10:37:49 2017 @@ -77,7 +77,9 @@ public class EntityClause { } public Object getValue() { - if (value == null) value = new Object(); + if (value == null) { + value = new Object(); + } return value; } 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=1818469&r1=1818468&r2=1818469&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 Sun Dec 17 10:37:49 2017 @@ -85,7 +85,6 @@ public abstract class EntityComparisonOp @Override public void addSqlValue(StringBuilder sql, ModelEntity entity, List<EntityConditionParam> entityConditionParams, boolean compat, L lhs, R rhs, Datasource datasourceInfo) { - //Debug.logInfo("EntityComparisonOperator.addSqlValue field=" + lhs + ", value=" + rhs + ", value type=" + (rhs == null ? "null object" : rhs.getClass().getName()), module); // if this is an IN operator and the rhs Object isEmpty, add "1=0" instead of the normal SQL. Note that "FALSE" does not work with all databases. if (this.idInt == EntityOperator.ID_IN && UtilValidate.isEmpty(rhs)) { @@ -160,7 +159,9 @@ public abstract class EntityComparisonOp rightValue = rhs; } - if (leftValue == WILDCARD || rightValue == WILDCARD) return true; + if (leftValue == WILDCARD || rightValue == WILDCARD) { + return true; + } return compare(UtilGenerics.<L>cast(leftValue), UtilGenerics.<R>cast(rightValue)); } @@ -173,9 +174,8 @@ public abstract class EntityComparisonOp if (item instanceof EntityConditionValue) { EntityConditionValue ecv = (EntityConditionValue) item; return ecv.freeze(); - } else { - return item; } + return item; } public EntityComparisonOperator(int id, String code) { @@ -252,15 +252,13 @@ public abstract class EntityComparisonOp if (lhs == null) { if (rhs != null) { return false; - } else { - return true; } + return true; } else if (rhs instanceof Collection<?>) { if (((Collection<?>) rhs).contains(lhs)) { return true; - } else { - return false; } + return false; } else if (lhs.equals(rhs)) { return true; } else { Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityCondition.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityCondition.java?rev=1818469&r1=1818468&r2=1818469&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityCondition.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityCondition.java Sun Dec 17 10:37:49 2017 @@ -57,19 +57,19 @@ public abstract class EntityCondition ex } public static <T extends EntityCondition> EntityConditionList<T> makeCondition(EntityJoinOperator operator, T... conditionList) { - return new EntityConditionList<T>(Arrays.<T>asList(conditionList), operator); + return new EntityConditionList<>(Arrays.<T>asList(conditionList), operator); } public static <T extends EntityCondition> EntityConditionList<T> makeCondition(T... conditionList) { - return new EntityConditionList<T>(Arrays.<T>asList(conditionList), EntityOperator.AND); + return new EntityConditionList<>(Arrays.<T>asList(conditionList), EntityOperator.AND); } public static <T extends EntityCondition> EntityConditionList<T> makeCondition(List<T> conditionList, EntityJoinOperator operator) { - return new EntityConditionList<T>(conditionList, operator); + return new EntityConditionList<>(conditionList, operator); } public static <T extends EntityCondition> EntityConditionList<T> makeCondition(List<T> conditionList) { - return new EntityConditionList<T>(conditionList, EntityOperator.AND); + return new EntityConditionList<>(conditionList, EntityOperator.AND); } public static <L,R> EntityFieldMap makeCondition(Map<String, ? extends Object> fieldMap, EntityComparisonOperator<L,R> compOp, EntityJoinOperator joinOp) { Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionBase.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionBase.java?rev=1818469&r1=1818468&r2=1818469&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionBase.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionBase.java Sun Dec 17 10:37:49 2017 @@ -58,7 +58,9 @@ public abstract class EntityConditionBas } protected String getColName(Map<String, String> tableAliases, ModelEntity modelEntity, String fieldName, boolean includeTableNamePrefix, Datasource datasourceInfo) { - if (modelEntity == null) return fieldName; + if (modelEntity == null) { + return fieldName; + } return getColName(tableAliases, modelEntity, getField(modelEntity, fieldName), fieldName, includeTableNamePrefix, datasourceInfo); } @@ -73,7 +75,9 @@ public abstract class EntityConditionBas } protected String getColName(Map<String, String> tableAliases, ModelEntity modelEntity, ModelField modelField, String fieldName, boolean includeTableNamePrefix, Datasource datasourceInfo) { - if (modelEntity == null || modelField == null) return fieldName; + if (modelEntity == null || modelField == null) { + return fieldName; + } // if this is a view entity and we are configured to alias the views, use the alias here instead of the composite (ie table.column) field name if (datasourceInfo != null && datasourceInfo.getAliasViewColumns() && modelEntity instanceof ModelViewEntity) { Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionFunction.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionFunction.java?rev=1818469&r1=1818468&r2=1818469&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionFunction.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionFunction.java Sun Dec 17 10:37:49 2017 @@ -69,8 +69,9 @@ public abstract class EntityConditionFun } public String getCode() { - if (codeString == null) + if (codeString == null) { return "null"; + } return codeString; } @@ -85,7 +86,9 @@ public abstract class EntityConditionFun @Override public boolean equals(Object obj) { - if (!(obj instanceof EntityConditionFunction)) return false; + if (!(obj instanceof EntityConditionFunction)) { + return false; + } EntityConditionFunction otherFunc = (EntityConditionFunction) obj; return this.idInt.equals(otherFunc.idInt) && (this.condition != null ? condition.equals(otherFunc.condition) : otherFunc.condition != null); } 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=1818469&r1=1818468&r2=1818469&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 Sun Dec 17 10:37:49 2017 @@ -72,7 +72,6 @@ public abstract class EntityConditionLis @Override public String makeWhereString(ModelEntity modelEntity, List<EntityConditionParam> entityConditionParams, Datasource datasourceInfo) { - // if (Debug.verboseOn()) Debug.logVerbose("makeWhereString for entity " + modelEntity.getEntityName(), module); StringBuilder sql = new StringBuilder(); operator.addSqlValue(sql, modelEntity, entityConditionParams, conditionList, datasourceInfo); return sql.toString(); @@ -80,7 +79,6 @@ public abstract class EntityConditionLis @Override public void checkCondition(ModelEntity modelEntity) throws GenericModelException { - // if (Debug.verboseOn()) Debug.logVerbose("checkCondition for entity " + modelEntity.getEntityName(), module); operator.validateSql(modelEntity, conditionList); } @@ -96,15 +94,12 @@ public abstract class EntityConditionLis @Override public boolean equals(Object obj) { - if (!(obj instanceof EntityConditionListBase<?>)) return false; + if (!(obj instanceof EntityConditionListBase<?>)) { + return false; + } EntityConditionListBase<?> other = UtilGenerics.cast(obj); boolean isEqual = conditionList.equals(other.conditionList) && operator.equals(other.operator); - //if (!isEqual) { - // Debug.logWarning("EntityConditionListBase.equals is false:\n this.operator=" + this.operator + "; other.operator=" + other.operator + - // "\nthis.conditionList=" + this.conditionList + - // "\nother.conditionList=" + other.conditionList, module); - //} return isEqual; } Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionSubSelect.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionSubSelect.java?rev=1818469&r1=1818468&r2=1818469&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionSubSelect.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionSubSelect.java Sun Dec 17 10:37:49 2017 @@ -149,6 +149,8 @@ public class EntityConditionSubSelect ex @Override public void visit(EntityConditionVisitor visitor) { - if (whereCond != null) whereCond.visit(visitor); + if (whereCond != null) { + whereCond.visit(visitor); + } } } Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityDateFilterCondition.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityDateFilterCondition.java?rev=1818469&r1=1818468&r2=1818469&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityDateFilterCondition.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityDateFilterCondition.java Sun Dec 17 10:37:49 2017 @@ -30,7 +30,7 @@ import org.apache.ofbiz.entity.config.mo import org.apache.ofbiz.entity.model.ModelEntity; /** - * Date-range condition. + * Date-range condition. * */ @SuppressWarnings("serial") @@ -69,7 +69,9 @@ public final class EntityDateFilterCondi @Override public boolean equals(Object obj) { - if (!(obj instanceof EntityDateFilterCondition)) return false; + if (!(obj instanceof EntityDateFilterCondition)) { + return false; + } EntityDateFilterCondition other = (EntityDateFilterCondition) obj; return equals(fromDateName, other.fromDateName) && equals(thruDateName, other.thruDateName); } @@ -115,15 +117,15 @@ public final class EntityDateFilterCondi } /** - * Creates an EntityCondition representing a date range filter query to be used against - * entities that themselves represent a date range. When used the resulting entities + * Creates an EntityCondition representing a date range filter query to be used against + * entities that themselves represent a date range. When used the resulting entities * will meet at least one of the following criteria: * - fromDate is equal to or after rangeStart but before rangeEnd * - thruDate is equal to or after rangeStart but before rangeEnd * - fromDate is null and thruDate is equal to or after rangeStart * - thruDate is null and fromDate is before rangeEnd * - fromDate is null and thruDate is null - * + * * @param rangeStart The start of the range to filter against * @param rangeEnd The end of the range to filter against * @param fromDateName The name of the field containing the entity's "fromDate" 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=1818469&r1=1818468&r2=1818469&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 Sun Dec 17 10:37:49 2017 @@ -75,8 +75,6 @@ public final class EntityExpr extends En } this.operator = UtilGenerics.cast(operator); this.rhs = rhs; - - //Debug.logInfo("new EntityExpr internal field=" + lhs + ", value=" + rhs + ", value type=" + (rhs == null ? "null object" : rhs.getClass().getName()), module); } public EntityExpr(EntityCondition lhs, EntityJoinOperator operator, EntityCondition rhs) { @@ -114,7 +112,6 @@ public final class EntityExpr extends En @Override public String makeWhereString(ModelEntity modelEntity, List<EntityConditionParam> entityConditionParams, Datasource datasourceInfo) { - // if (Debug.verboseOn()) Debug.logVerbose("makeWhereString for entity " + modelEntity.getEntityName(), module); this.checkRhsType(modelEntity, null); @@ -130,7 +127,6 @@ public final class EntityExpr extends En @Override public void checkCondition(ModelEntity modelEntity) throws GenericModelException { - // if (Debug.verboseOn()) Debug.logVerbose("checkCondition for entity " + modelEntity.getEntityName(), module); if (lhs instanceof EntityCondition) { ((EntityCondition) lhs).checkCondition(modelEntity); ((EntityCondition) rhs).checkCondition(modelEntity); @@ -163,7 +159,9 @@ public final class EntityExpr extends En } public void checkRhsType(ModelEntity modelEntity, Delegator delegator) { - if (this.rhs == null || this.rhs == GenericEntity.NULL_FIELD || modelEntity == null) return; + if (this.rhs == null || this.rhs == GenericEntity.NULL_FIELD || modelEntity == null) { + return; + } Object value = this.rhs; if (this.rhs instanceof EntityFunction<?>) { @@ -267,16 +265,13 @@ public final class EntityExpr extends En @Override public boolean equals(Object obj) { - if (!(obj instanceof EntityExpr)) return false; + if (!(obj instanceof EntityExpr)) { + return false; + } EntityExpr other = (EntityExpr) obj; boolean isEqual = equals(lhs, other.lhs) && equals(operator, other.operator) && equals(rhs, other.rhs); - //if (!isEqual) { - // Debug.logWarning("EntityExpr.equals is false for: \n-this.lhs=" + this.lhs + "; other.lhs=" + other.lhs + - // "\nthis.operator=" + this.operator + "; other.operator=" + other.operator + - // "\nthis.rhs=" + this.rhs + "other.rhs=" + other.rhs, module); - //} return isEqual; } 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=1818469&r1=1818468&r2=1818469&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 Sun Dec 17 10:37:49 2017 @@ -93,19 +93,33 @@ public class EntityFieldValue extends En @Override public int hashCode() { int hash = fieldName.hashCode(); - if (this.entityAlias != null) hash |= this.entityAlias.hashCode(); - if (this.entityAliasStack != null) hash |= this.entityAliasStack.hashCode(); - if (this.modelViewEntity != null) hash |= this.modelViewEntity.hashCode(); + if (this.entityAlias != null) { + hash |= this.entityAlias.hashCode(); + } + if (this.entityAliasStack != null) { + hash |= this.entityAliasStack.hashCode(); + } + if (this.modelViewEntity != null) { + hash |= this.modelViewEntity.hashCode(); + } return hash; } @Override public boolean equals(Object obj) { - if (!(obj instanceof EntityFieldValue)) return false; + if (!(obj instanceof EntityFieldValue)) { + 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; + 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; } Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityFunction.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityFunction.java?rev=1818469&r1=1818468&r2=1818469&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityFunction.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityFunction.java Sun Dec 17 10:37:49 2017 @@ -180,7 +180,9 @@ public abstract class EntityFunction<T e @Override public boolean equals(Object obj) { - if (!(obj instanceof EntityFunction<?>)) return false; + if (!(obj instanceof EntityFunction<?>)) { + return false; + } EntityFunction<?> otherFunc = UtilGenerics.cast(obj); return (this.function == otherFunc.function && (this.nested != null ? nested.equals(otherFunc.nested) : otherFunc.nested == null) && 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=1818469&r1=1818468&r2=1818469&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 Sun Dec 17 10:37:49 2017 @@ -130,8 +130,12 @@ 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) return shortCircuitValue; + if (lhs.entityMatches(entity) == shortCircuitValue) { + return shortCircuitValue; + } + if (rhs.entityMatches(entity) == shortCircuitValue) { + return shortCircuitValue; + } return !shortCircuitValue; } @@ -145,8 +149,12 @@ 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) return shortCircuitValue; + if (lhs.mapMatches(delegator, map) == shortCircuitValue) { + return shortCircuitValue; + } + if (rhs.mapMatches(delegator, map) == shortCircuitValue) { + return shortCircuitValue; + } return !shortCircuitValue; } @@ -157,7 +165,9 @@ public class EntityJoinOperator extends public boolean mapMatches(Delegator delegator, Map<String, ? extends Object> map, List<? extends EntityCondition> conditionList) { if (UtilValidate.isNotEmpty(conditionList)) { for (EntityCondition condition: conditionList) { - if (condition.mapMatches(delegator, map) == shortCircuitValue) return shortCircuitValue; + if (condition.mapMatches(delegator, map) == shortCircuitValue) { + return shortCircuitValue; + } } } return !shortCircuitValue; Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityOperator.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityOperator.java?rev=1818469&r1=1818468&r2=1818469&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityOperator.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityOperator.java Sun Dec 17 10:37:49 2017 @@ -58,7 +58,7 @@ public abstract class EntityOperator<L, public static final int ID_NOT_LIKE = 14; private static final AtomicInteger dynamicId = new AtomicInteger(); - private static HashMap<String, EntityOperator<?,?,?>> registry = new HashMap<String, EntityOperator<?,?,?>>(); + private static HashMap<String, EntityOperator<?,?,?>> registry = new HashMap<>(); private static <L,R,T> void registerCase(String name, EntityOperator<L,R,T> operator) { registry.put(name.toLowerCase(Locale.getDefault()), operator); @@ -77,15 +77,17 @@ public abstract class EntityOperator<L, public static <L,R> EntityComparisonOperator<L,R> lookupComparison(String name) { EntityOperator<?,?,Boolean> operator = lookup(name); - if (!(operator instanceof EntityComparisonOperator<?,?>)) + if (!(operator instanceof EntityComparisonOperator<?,?>)) { throw new IllegalArgumentException(name + " is not a comparison operator"); + } return UtilGenerics.cast(operator); } public static EntityJoinOperator lookupJoin(String name) { EntityOperator<?,?,Boolean> operator = lookup(name); - if (!(operator instanceof EntityJoinOperator)) + if (!(operator instanceof EntityJoinOperator)) { throw new IllegalArgumentException(name + " is not a join operator"); + } return UtilGenerics.cast(operator); } @@ -99,10 +101,8 @@ public abstract class EntityOperator<L, @Override protected void makeRHSWhereString(ModelEntity entity, List<EntityConditionParam> entityConditionParams, StringBuilder sb, ModelField field, Object rhs, Datasource datasourceInfo) { if (rhs == null || rhs == GenericEntity.NULL_FIELD) { - //Debug.logInfo("makeRHSWhereString: field IS NULL: " + field.getName(), module); sb.append(" IS NULL"); } else { - //Debug.logInfo("makeRHSWhereString: field not null, doing super: " + field.getName() + ", type: " + rhs.getClass().getName() + ", value: " + rhs, module); super.makeRHSWhereString(entity, entityConditionParams, sb, field, rhs, datasourceInfo); } } @@ -300,7 +300,9 @@ public abstract class EntityOperator<L, public static final Comparable<?> WILDCARD = new Comparable<Object>() { public int compareTo(Object obj) { - if (obj != WILDCARD) throw new ClassCastException(); + if (obj != WILDCARD) { + throw new ClassCastException(); + } return 0; } Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityWhereString.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityWhereString.java?rev=1818469&r1=1818468&r2=1818469&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityWhereString.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityWhereString.java Sun Dec 17 10:37:49 2017 @@ -88,7 +88,9 @@ public final class EntityWhereString ext @Override public boolean equals(Object obj) { - if (!(obj instanceof EntityWhereString)) return false; + if (!(obj instanceof EntityWhereString)) { + return false; + } EntityWhereString other = (EntityWhereString) obj; return equals(sqlString, other.sqlString); } Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByItem.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByItem.java?rev=1818469&r1=1818468&r2=1818469&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByItem.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByItem.java Sun Dec 17 10:37:49 2017 @@ -206,7 +206,9 @@ public class OrderByItem implements Comp @Override public boolean equals(java.lang.Object obj) { - if (!(obj instanceof OrderByItem)) return false; + if (!(obj instanceof OrderByItem)) { + return false; + } OrderByItem that = (OrderByItem) obj; return getValue().equals(that.getValue()) && getDescending() == that.getDescending(); Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByList.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByList.java?rev=1818469&r1=1818468&r2=1818469&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByList.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByList.java Sun Dec 17 10:37:49 2017 @@ -88,7 +88,9 @@ public class OrderByList implements Comp sb.append(" ORDER BY "); } for (int i = 0; i < orderByList.size(); i++) { - if (i != 0) sb.append(", "); + if (i != 0) { + sb.append(", "); + } OrderByItem orderByItem = orderByList.get(i); orderByItem.makeOrderByString(sb, modelEntity, includeTablenamePrefix, datasourceInfo); } @@ -98,7 +100,9 @@ public class OrderByList implements Comp int result = 0; for (OrderByItem orderByItem: orderByList) { result = orderByItem.compare(entity1, entity2); - if (result != 0) break; + if (result != 0) { + break; + } } return result; } @@ -113,7 +117,9 @@ public class OrderByList implements Comp @Override public boolean equals(java.lang.Object obj) { - if (!(obj instanceof OrderByList)) return false; + if (!(obj instanceof OrderByList)) { + return false; + } OrderByList that = (OrderByList) obj; return orderByList.equals(that.orderByList); } |
Free forum by Nabble | Edit this page |