Author: doogie
Date: Tue Nov 17 06:29:56 2009
New Revision: 881169
URL:
http://svn.apache.org/viewvc?rev=881169&view=revLog:
Add a helper method, reduce, for list processing.
Modified:
ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Parser.jj
Modified: ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Parser.jj
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Parser.jj?rev=881169&r1=881168&r2=881169&view=diff==============================================================================
--- ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Parser.jj (original)
+++ ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Parser.jj Tue Nov 17 06:29:56 2009
@@ -47,6 +47,12 @@
import javolution.util.FastMap;
public final class Parser {
+ private Condition reduce(List<Condition> conditions, Joiner joiner) {
+ if (conditions.size() == 1) {
+ return conditions.get(0);
+ }
+ return new ConditionList(joiner, conditions);
+ }
}
PARSER_END(Parser)
@@ -683,7 +689,7 @@
{
c=BooleanExpression() { list.add(c); }
( <AND> c=BooleanExpression() { list.add(c); } )*
- { return list.size() == 1 ? list.get(0) : new ConditionList(Joiner.AND, list); }
+ { return reduce(list, Joiner.AND); }
}
private Condition OrExpression():
@@ -694,7 +700,7 @@
{
c=AndExpression() { list.add(c); }
( <OR> c=AndExpression() { list.add(c); } )*
- { return list.size() == 1 ? list.get(0) : new ConditionList(Joiner.OR, list); }
+ { return reduce(list, Joiner.OR); }
}
private Value RightValue():