Author: pgil
Date: Fri Jan 4 15:02:45 2019
New Revision: 1850385
URL: http://svn.apache.org/viewvc?rev=1850385&view=rev
Log:
Improved: Refactoring ‘EntityCondition’ - Rewrite EntityConditionListBase class
(OFBIZ-10691)
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
Modified:
ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionList.java
ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionListBase.java
Modified:
ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionList.java
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionList.java?rev=1850385&r1=1850384&r2=1850385&view=diff
==============================================================================
---
ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionList.java
(original)
+++
ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionList.java
Fri Jan 4 15:02:45 2019
@@ -47,7 +47,7 @@ public final class EntityConditionList<T
* @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<T
*/
@SuppressWarnings("unchecked")
public Iterator<T> getConditionIterator() {
- return (Iterator<T>)conditionList.iterator();
+ return (Iterator<T>)conditions.iterator();
}
@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=1850385&r1=1850384&r2=1850385&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 Jan 4 15:02:45 2019
@@ -28,54 +28,71 @@ import org.apache.ofbiz.entity.config.mo
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<T extends EntityCondition>
implements EntityCondition {
+abstract class EntityConditionListBase<T extends EntityCondition> implements
EntityCondition {
public static final String module =
EntityConditionListBase.class.getName();
-
- protected final List<? extends T> conditionList;
+ /** The list of condition expressions to combine. */
+ protected final List<? extends T> conditions;
+ /** The infix operator used to combine every elements in the list of
conditions. */
protected final EntityJoinOperator operator;
- protected EntityConditionListBase(List<? extends T> 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<? extends T> 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<EntityConditionParam> 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<String, ? extends
Object> 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 EntityConditionLis
}
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