diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityClause.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityClause.java index c869d68984..13ebd9bef7 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityClause.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityClause.java @@ -77,7 +77,9 @@ public class EntityClause { } public Object getValue() { - if (value == null) value = new Object(); + if (value == null) { + value = new Object(); + } return value; } diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityComparisonOperator.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityComparisonOperator.java index 92faa0c712..add2016d42 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityComparisonOperator.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityComparisonOperator.java @@ -85,7 +85,6 @@ public abstract class EntityComparisonOperator extends EntityOperator 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 EntityComparisonOperator extends EntityOperatorcast(leftValue), UtilGenerics.cast(rightValue)); } @@ -173,9 +174,8 @@ public abstract class EntityComparisonOperator extends EntityOperator extends EntityOperator) { if (((Collection) rhs).contains(lhs)) { return true; - } else { - return false; } + return false; } else if (lhs.equals(rhs)) { return true; } else { diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityCondition.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityCondition.java index f40348990d..b6adac2a61 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityCondition.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityCondition.java @@ -57,19 +57,19 @@ public abstract class EntityCondition extends EntityConditionBase implements IsE } public static EntityConditionList makeCondition(EntityJoinOperator operator, T... conditionList) { - return new EntityConditionList(Arrays.asList(conditionList), operator); + return new EntityConditionList<>(Arrays.asList(conditionList), operator); } public static EntityConditionList makeCondition(T... conditionList) { - return new EntityConditionList(Arrays.asList(conditionList), EntityOperator.AND); + return new EntityConditionList<>(Arrays.asList(conditionList), EntityOperator.AND); } public static EntityConditionList makeCondition(List conditionList, EntityJoinOperator operator) { - return new EntityConditionList(conditionList, operator); + return new EntityConditionList<>(conditionList, operator); } public static EntityConditionList makeCondition(List conditionList) { - return new EntityConditionList(conditionList, EntityOperator.AND); + return new EntityConditionList<>(conditionList, EntityOperator.AND); } public static EntityFieldMap makeCondition(Map fieldMap, EntityComparisonOperator compOp, EntityJoinOperator joinOp) { diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionBase.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionBase.java index f2977cb08a..c0bcfb83c7 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionBase.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionBase.java @@ -58,7 +58,9 @@ public abstract class EntityConditionBase implements Serializable { } protected String getColName(Map 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 EntityConditionBase implements Serializable { } protected String getColName(Map 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) { diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionFunction.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionFunction.java index 782c52be3a..bc0c84adf0 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionFunction.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionFunction.java @@ -69,8 +69,9 @@ public abstract class EntityConditionFunction extends EntityCondition { } public String getCode() { - if (codeString == null) + if (codeString == null) { return "null"; + } return codeString; } @@ -85,7 +86,9 @@ public abstract class EntityConditionFunction extends EntityCondition { @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); } diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionListBase.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionListBase.java index 937576b5bc..89229e868f 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionListBase.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionListBase.java @@ -72,7 +72,6 @@ public abstract class EntityConditionListBase extends @Override public String makeWhereString(ModelEntity modelEntity, List 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 EntityConditionListBase extends @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 EntityConditionListBase extends @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; } diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionSubSelect.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionSubSelect.java index 58c61a4fd0..96272e2bbf 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionSubSelect.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionSubSelect.java @@ -149,6 +149,8 @@ public class EntityConditionSubSelect extends EntityConditionValue { @Override public void visit(EntityConditionVisitor visitor) { - if (whereCond != null) whereCond.visit(visitor); + if (whereCond != null) { + whereCond.visit(visitor); + } } } diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityDateFilterCondition.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityDateFilterCondition.java index d2f911b0a7..29a0849329 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityDateFilterCondition.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityDateFilterCondition.java @@ -30,7 +30,7 @@ import org.apache.ofbiz.entity.config.model.Datasource; import org.apache.ofbiz.entity.model.ModelEntity; /** - * Date-range condition. + * Date-range condition. * */ @SuppressWarnings("serial") @@ -69,7 +69,9 @@ public final class EntityDateFilterCondition extends EntityCondition { @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 EntityDateFilterCondition extends EntityCondition { } /** - * 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" diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityExpr.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityExpr.java index a48bf59f0c..7835683f82 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityExpr.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityExpr.java @@ -75,8 +75,6 @@ public final class EntityExpr extends EntityCondition { } 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 EntityCondition { @Override public String makeWhereString(ModelEntity modelEntity, List 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 EntityCondition { @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 EntityCondition { } 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 EntityCondition { @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; } diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityFieldValue.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityFieldValue.java index 378adcb30b..d66d5eea2e 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityFieldValue.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityFieldValue.java @@ -93,19 +93,33 @@ public class EntityFieldValue extends EntityConditionValue { @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; } diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityFunction.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityFunction.java index ffd8ea457c..65cba8d76d 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityFunction.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityFunction.java @@ -180,7 +180,9 @@ public abstract class EntityFunction> extends EntityCond @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) && diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityJoinOperator.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityJoinOperator.java index 948d4970b3..16d349c93f 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityJoinOperator.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityJoinOperator.java @@ -130,8 +130,12 @@ public class EntityJoinOperator extends EntityOperator 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 EntityOperator map, List 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; diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityOperator.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityOperator.java index 27c1a2cd25..860b3a5b8e 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityOperator.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityOperator.java @@ -58,7 +58,7 @@ public abstract class EntityOperator extends EntityConditionBase { public static final int ID_NOT_LIKE = 14; private static final AtomicInteger dynamicId = new AtomicInteger(); - private static HashMap> registry = new HashMap>(); + private static HashMap> registry = new HashMap<>(); private static void registerCase(String name, EntityOperator operator) { registry.put(name.toLowerCase(Locale.getDefault()), operator); @@ -77,15 +77,17 @@ public abstract class EntityOperator extends EntityConditionBase { public static EntityComparisonOperator lookupComparison(String name) { EntityOperator 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 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 extends EntityConditionBase { @Override protected void makeRHSWhereString(ModelEntity entity, List 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 extends EntityConditionBase { public static final Comparable WILDCARD = new Comparable() { public int compareTo(Object obj) { - if (obj != WILDCARD) throw new ClassCastException(); + if (obj != WILDCARD) { + throw new ClassCastException(); + } return 0; } diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityWhereString.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityWhereString.java index c36694f058..d1d1766d63 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityWhereString.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityWhereString.java @@ -88,7 +88,9 @@ public final class EntityWhereString extends EntityCondition { @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); } diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByItem.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByItem.java index 567d03c45d..adeeff193a 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByItem.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByItem.java @@ -206,7 +206,9 @@ public class OrderByItem implements Comparator { @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(); diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByList.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByList.java index 0aa158326e..7a2edefdd0 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByList.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByList.java @@ -88,7 +88,9 @@ public class OrderByList implements Comparator { 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 Comparator { 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 Comparator { @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); }