From 00ee97b23dffa284d92041267aea0d052abc3898 Mon Sep 17 00:00:00 2001 From: Gil Portenseigne Date: Fri, 4 Jan 2019 15:02:45 +0000 Subject: [PATCH] =?UTF-8?q?Improved:=20Refactoring=20=E2=80=98EntityCondit?= =?UTF-8?q?ion=E2=80=99=20-=20Rewrite=20EntityConditionListBase=20class=20?= =?UTF-8?q?(OFBIZ-10691)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unecessary ‘this’ has been removed and the javadoc has been expanded. The visibility of the class has been reduced to package only. The ‘conditionList’ field has been renamed to ‘conditions’ and the subclasses has been adapted. Thanks Mathieu for the contribution git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1850385 13f79535-47bb-0310-9956-ffa450edef68 --- .../entity/condition/EntityConditionList.java | 4 +- .../condition/EntityConditionListBase.java | 49 +++++++++++++------ 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionList.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionList.java index f15a50482c..ea20157137 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionList.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionList.java @@ -47,7 +47,7 @@ public final class EntityConditionList extends Entity * @return the size of the internal list of condition expressions */ public int getConditionListSize() { - return conditionList.size(); + return conditions.size(); } /** @@ -57,7 +57,7 @@ public final class EntityConditionList extends Entity */ @SuppressWarnings("unchecked") public Iterator getConditionIterator() { - return (Iterator)conditionList.iterator(); + return (Iterator)conditions.iterator(); } @Override 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 c912cc6200..54bdf9cbe1 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 @@ -28,54 +28,71 @@ import org.apache.ofbiz.entity.config.model.Datasource; import org.apache.ofbiz.entity.model.ModelEntity; /** - * Encapsulates a list of EntityConditions to be used as a single EntityCondition combined as specified - * + * Represents a combination of multiple condition expressions. */ @SuppressWarnings("serial") -public abstract class EntityConditionListBase implements EntityCondition { +abstract class EntityConditionListBase implements EntityCondition { public static final String module = EntityConditionListBase.class.getName(); - - protected final List conditionList; + /** The list of condition expressions to combine. */ + protected final List conditions; + /** The infix operator used to combine every elements in the list of conditions. */ protected final EntityJoinOperator operator; - protected EntityConditionListBase(List conditionList, EntityJoinOperator operator) { - this.conditionList = conditionList; + /** + * Constructs a combination of multiple condition expressions. + * + * @param conditions the list of condition expressions to combine + * @param operator the infix operator used to combine every elements in the list of conditions + */ + protected EntityConditionListBase(List conditions, EntityJoinOperator operator) { + this.conditions = conditions; this.operator = operator; } + /** + * Gets the infix operator used to combine every elements in the list of conditions. + * + * @return the infix operator used to combine every elements in the list of conditions. + */ public EntityJoinOperator getOperator() { - return this.operator; + return operator; } + /** + * Gets the condition expression stored at a particular of the internal list of conditions. + * + * @param index the index of the condition expression to find + * @return the corresponding condition expression + */ public T getCondition(int index) { - return this.conditionList.get(index); + return conditions.get(index); } @Override public boolean isEmpty() { - return operator.isEmpty(conditionList); + return operator.isEmpty(conditions); } @Override public String makeWhereString(ModelEntity modelEntity, List entityConditionParams, Datasource datasourceInfo) { StringBuilder sql = new StringBuilder(); - operator.addSqlValue(sql, modelEntity, entityConditionParams, conditionList, datasourceInfo); + operator.addSqlValue(sql, modelEntity, entityConditionParams, conditions, datasourceInfo); return sql.toString(); } @Override public void checkCondition(ModelEntity modelEntity) throws GenericModelException { - operator.validateSql(modelEntity, conditionList); + operator.validateSql(modelEntity, conditions); } @Override public boolean mapMatches(Delegator delegator, Map map) { - return operator.mapMatches(delegator, map, conditionList); + return operator.mapMatches(delegator, map, conditions); } @Override public EntityCondition freeze() { - return operator.freeze(conditionList); + return operator.freeze(conditions); } @Override @@ -85,12 +102,12 @@ public abstract class EntityConditionListBase impleme } EntityConditionListBase other = UtilGenerics.cast(obj); - return conditionList.equals(other.conditionList) && operator.equals(other.operator); + return conditions.equals(other.conditions) && operator.equals(other.operator); } @Override public int hashCode() { - return conditionList.hashCode() + operator.hashCode(); + return conditions.hashCode() + operator.hashCode(); } @Override