Improved: Refactoring ‘EntityCondition’ - Rewrite EntityConditionList class

(OFBIZ-10691)

This class is now final.  The ‘getConditionListSize’ and
‘getConditionIterator’ methods has been inlined instead of overidding
them from ‘EntityConditionListBase’.  The Javadoc has been expanded.

Thanks Mathieu for the contribution

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1850377 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gil Portenseigne
2019-01-04 14:56:13 +00:00
parent 31fdaaed84
commit 682f29be45
2 changed files with 26 additions and 17 deletions
@@ -22,23 +22,42 @@ import java.util.Iterator;
import java.util.List;
/**
* Encapsulates a list of EntityConditions to be used as a single EntityCondition combined as specified
*
* A condition expression corresponding to an ordered collection of conditions
* that are joined by an operator.
* <p>
* The main objective it to express the conjunction or disjunction of a set of
* conditions which in the case of conjunction corresponds to SQL expression
* of the form {@code foo=bar AND bar=baz AND ...}.
*/
@SuppressWarnings("serial")
public class EntityConditionList<T extends EntityCondition> extends EntityConditionListBase<T> {
public final class EntityConditionList<T extends EntityCondition> extends EntityConditionListBase<T> {
/**
* Constructs an entity condition list.
*
* @param conditionList the list of conditions
* @param operator the operator used to join the list of conditions
*/
public EntityConditionList(List<? extends T> conditionList, EntityJoinOperator operator) {
super(conditionList, operator);
}
@Override
/**
* Provides the size of the internal list of condition expressions.
*
* @return the size of the internal list of condition expressions
*/
public int getConditionListSize() {
return super.getConditionListSize();
return conditionList.size();
}
@Override
/**
* Provides an iterator to iterate on the internal list of condition expressions.
*
* @return an iterator iterating on the internal list of condition expressions
*/
@SuppressWarnings("unchecked")
public Iterator<T> getConditionIterator() {
return super.getConditionIterator();
return (Iterator<T>)conditionList.iterator();
}
@Override
@@ -18,7 +18,6 @@
*******************************************************************************/
package org.apache.ofbiz.entity.condition;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -52,15 +51,6 @@ public abstract class EntityConditionListBase<T extends EntityCondition> impleme
return this.conditionList.get(index);
}
protected int getConditionListSize() {
return this.conditionList.size();
}
@SuppressWarnings("unchecked")
protected Iterator<T> getConditionIterator() {
return (Iterator<T>)this.conditionList.iterator();
}
@Override
public boolean isEmpty() {
return operator.isEmpty(conditionList);