svn commit: r1604969 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1604969 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/

doogie-3
Author: doogie
Date: Tue Jun 24 00:23:32 2014
New Revision: 1604969

URL: http://svn.apache.org/r1604969
Log:
This is the first phase at making EntityCondition objects immutable; the
classes/fields not yet finalized are left undone due to there being
side-effects with other parts of the code base.  These side-effects will
be fixed shortly.

Modified:
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityCondition.java
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionList.java
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionListBase.java
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionValue.java
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityDateFilterCondition.java
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldMap.java
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFunction.java
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityWhereString.java

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityCondition.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityCondition.java?rev=1604969&r1=1604968&r2=1604969&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityCondition.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityCondition.java Tue Jun 24 00:23:32 2014
@@ -21,11 +21,10 @@ package org.ofbiz.entity.condition;
 import static org.ofbiz.base.util.UtilGenerics.cast;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 
-import javolution.lang.Reusable;
-
 import org.ofbiz.base.lang.IsEmpty;
 import org.ofbiz.entity.Delegator;
 import org.ofbiz.entity.GenericEntity;
@@ -45,96 +44,66 @@ import org.ofbiz.entity.model.ModelEntit
  *
  */
 @SuppressWarnings("serial")
-public abstract class EntityCondition extends EntityConditionBase implements IsEmpty, Reusable {
+public abstract class EntityCondition extends EntityConditionBase implements IsEmpty {
 
     public static <L,R,LL,RR> EntityExpr makeCondition(L lhs, EntityComparisonOperator<LL,RR> operator, R rhs) {
-        EntityExpr expr = new EntityExpr();
-        expr.init(lhs, operator, rhs);
-        return expr;
+        return new EntityExpr(lhs, operator, rhs);
     }
 
     public static <R> EntityExpr makeCondition(String fieldName, R value) {
-        EntityExpr expr = new EntityExpr();
-        expr.init(fieldName, EntityOperator.EQUALS, value);
-        return expr;
+        return new EntityExpr(fieldName, EntityOperator.EQUALS, value);
     }
 
     public static EntityExpr makeCondition(EntityCondition lhs, EntityJoinOperator operator, EntityCondition rhs) {
-        EntityExpr expr = new EntityExpr();
-        expr.init(lhs, operator, rhs);
-        return expr;
+        return new EntityExpr(lhs, operator, rhs);
     }
 
     public static <T extends EntityCondition> EntityConditionList<T> makeCondition(EntityJoinOperator operator, T... conditionList) {
-        EntityConditionList<T> ecl = cast(new EntityConditionList<T>());
-        ecl.init(operator, conditionList);
-        return ecl;
+        return new EntityConditionList<T>(Arrays.<T>asList(conditionList), operator);
     }
 
     public static <T extends EntityCondition> EntityConditionList<T> makeCondition(T... conditionList) {
-        EntityConditionList<T> ecl = cast(new EntityConditionList<T>());
-        ecl.init(EntityOperator.AND, conditionList);
-        return ecl;
+        return new EntityConditionList<T>(Arrays.<T>asList(conditionList), EntityOperator.AND);
     }
 
     public static <T extends EntityCondition> EntityConditionList<T> makeCondition(List<T> conditionList, EntityJoinOperator operator) {
-        EntityConditionList<T> ecl = cast(new EntityConditionList<T>());
-        ecl.init(conditionList, operator);
-        return ecl;
+        return new EntityConditionList<T>(conditionList, operator);
     }
 
     public static <T extends EntityCondition> EntityConditionList<T> makeCondition(List<T> conditionList) {
-        EntityConditionList<T> ecl = cast(new EntityConditionList<T>());
-        ecl.init(conditionList, EntityOperator.AND);
-        return ecl;
+        return new EntityConditionList<T>(conditionList, EntityOperator.AND);
     }
 
     public static <L,R> EntityFieldMap makeCondition(Map<String, ? extends Object> fieldMap, EntityComparisonOperator<L,R> compOp, EntityJoinOperator joinOp) {
-        EntityFieldMap efm = new EntityFieldMap();
-        efm.init(fieldMap, compOp, joinOp);
-        return efm;
+        return new EntityFieldMap(fieldMap, compOp, joinOp);
     }
 
     public static EntityFieldMap makeCondition(Map<String, ? extends Object> fieldMap, EntityJoinOperator joinOp) {
-        EntityFieldMap efm = new EntityFieldMap();
-        efm.init(fieldMap, EntityOperator.EQUALS, joinOp);
-        return efm;
+        return new EntityFieldMap(fieldMap, EntityOperator.EQUALS, joinOp);
     }
 
     public static EntityFieldMap makeCondition(Map<String, ? extends Object> fieldMap) {
-        EntityFieldMap efm = new EntityFieldMap();
-        efm.init(fieldMap, EntityOperator.EQUALS, EntityOperator.AND);
-        return efm;
+        return new EntityFieldMap(fieldMap, EntityOperator.EQUALS, EntityOperator.AND);
     }
 
     public static <L,R> EntityFieldMap makeCondition(EntityComparisonOperator<L,R> compOp, EntityJoinOperator joinOp, Object... keysValues) {
-        EntityFieldMap efm = new EntityFieldMap();
-        efm.init(compOp, joinOp, keysValues);
-        return efm;
+        return new EntityFieldMap(compOp, joinOp, keysValues);
     }
 
     public static EntityFieldMap makeCondition(EntityJoinOperator joinOp, Object... keysValues) {
-        EntityFieldMap efm = new EntityFieldMap();
-        efm.init(EntityOperator.EQUALS, joinOp, keysValues);
-        return efm;
+        return new EntityFieldMap(EntityOperator.EQUALS, joinOp, keysValues);
     }
 
     public static EntityFieldMap makeConditionMap(Object... keysValues) {
-        EntityFieldMap efm = new EntityFieldMap();
-        efm.init(EntityOperator.EQUALS, EntityOperator.AND, keysValues);
-        return efm;
+        return new EntityFieldMap(EntityOperator.EQUALS, EntityOperator.AND, keysValues);
     }
 
     public static EntityDateFilterCondition makeConditionDate(String fromDateName, String thruDateName) {
-        EntityDateFilterCondition edfc = new EntityDateFilterCondition();
-        edfc.init(fromDateName, thruDateName);
-        return edfc;
+        return new EntityDateFilterCondition(fromDateName, thruDateName);
     }
 
     public static EntityWhereString makeConditionWhere(String sqlString) {
-        EntityWhereString ews = new EntityWhereString();
-        ews.init(sqlString);
-        return ews;
+        return new EntityWhereString(sqlString);
     }
 
     @Override

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionList.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionList.java?rev=1604969&r1=1604968&r2=1604969&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionList.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionList.java Tue Jun 24 00:23:32 2014
@@ -19,6 +19,7 @@
 package org.ofbiz.entity.condition;
 
 import java.util.Iterator;
+import java.util.List;
 
 /**
  * Encapsulates a list of EntityConditions to be used as a single EntityCondition combined as specified
@@ -26,6 +27,14 @@ import java.util.Iterator;
  */
 @SuppressWarnings("serial")
 public class EntityConditionList<T extends EntityCondition> extends EntityConditionListBase<T> {
+    public EntityConditionList(List<T> conditionList, EntityJoinOperator operator) {
+        super(conditionList, operator);
+    }
+
+    public void init(List<T> conditionList, EntityJoinOperator operator) {
+        this.conditionList = conditionList;
+        this.operator = operator;
+    }
 
     @Override
     public int getConditionListSize() {

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionListBase.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionListBase.java?rev=1604969&r1=1604968&r2=1604969&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionListBase.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionListBase.java Tue Jun 24 00:23:32 2014
@@ -40,31 +40,11 @@ public abstract class EntityConditionLis
     protected List<T> conditionList = null;
     protected EntityJoinOperator operator = null;
 
-    protected EntityConditionListBase() {}
-
-    public EntityConditionListBase(EntityJoinOperator operator, T... conditionList) {
-        this.init(operator, conditionList);
-    }
-
-    public EntityConditionListBase(List<T> conditionList, EntityJoinOperator operator) {
-        this.init(conditionList, operator);
-    }
-
-    public void init(EntityJoinOperator operator, T... conditionList) {
-        this.conditionList = Arrays.asList(conditionList);
-        this.operator = operator;
-    }
-
-    public void init(List<T> conditionList, EntityJoinOperator operator) {
+    protected EntityConditionListBase(List<T> conditionList, EntityJoinOperator operator) {
         this.conditionList = conditionList;
         this.operator = operator;
     }
 
-    public void reset() {
-        this.conditionList = null;
-        this.operator = null;
-    }
-
     public EntityJoinOperator getOperator() {
         return this.operator;
     }

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionValue.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionValue.java?rev=1604969&r1=1604968&r2=1604969&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionValue.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionValue.java Tue Jun 24 00:23:32 2014
@@ -22,9 +22,6 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
-import javolution.context.ObjectFactory;
-import javolution.lang.Reusable;
-
 import org.ofbiz.entity.Delegator;
 import org.ofbiz.entity.GenericEntity;
 import org.ofbiz.entity.GenericModelException;
@@ -39,22 +36,11 @@ import org.ofbiz.entity.model.ModelField
 @SuppressWarnings("serial")
 public abstract class EntityConditionValue extends EntityConditionBase {
 
-    public static EntityConditionValue CONSTANT_NUMBER(Number value) { return ConstantNumberValue.createConstantNumberValue(value); }
-    public static class ConstantNumberValue extends EntityConditionValue implements Reusable {
-        protected static ConstantNumberValue createConstantNumberValue(Number value) {
-            ConstantNumberValue cnv = factory.object();
-            cnv.init(value);
-            return cnv;
-        }
-        protected static final ObjectFactory<ConstantNumberValue> factory = new ObjectFactory<ConstantNumberValue>() {
-            protected ConstantNumberValue create() {
-                return new ConstantNumberValue();
-            }
-        };
-
+    public static EntityConditionValue CONSTANT_NUMBER(Number value) { return new ConstantNumberValue(value); }
+    public static final class ConstantNumberValue extends EntityConditionValue {
         private Number value;
 
-        protected void init(Number value) {
+        private ConstantNumberValue(Number value) {
             this.value = value;
         }
 
@@ -84,11 +70,6 @@ public abstract class EntityConditionVal
         }
 
         @Override
-        public void reset() {
-            this.value = value;
-        }
-
-        @Override
         public void validateSql(org.ofbiz.entity.model.ModelEntity modelEntity) {
         }
 

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityDateFilterCondition.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityDateFilterCondition.java?rev=1604969&r1=1604968&r2=1604969&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityDateFilterCondition.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityDateFilterCondition.java Tue Jun 24 00:23:32 2014
@@ -34,21 +34,16 @@ import org.ofbiz.entity.model.ModelEntit
  *
  */
 @SuppressWarnings("serial")
-public class EntityDateFilterCondition extends EntityCondition {
+public final class EntityDateFilterCondition extends EntityCondition {
 
-    protected String fromDateName = null;
-    protected String thruDateName = null;
+    protected final String fromDateName;
+    protected final String thruDateName;
 
-    public void init(String fromDateName, String thruDateName) {
+    public EntityDateFilterCondition(String fromDateName, String thruDateName) {
         this.fromDateName = fromDateName;
         this.thruDateName = thruDateName;
     }
 
-    public void reset() {
-        this.fromDateName = null;
-        this.thruDateName = null;
-    }
-
     @Override
     public boolean isEmpty() {
         return false;

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java?rev=1604969&r1=1604968&r2=1604969&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java Tue Jun 24 00:23:32 2014
@@ -48,7 +48,7 @@ public class EntityExpr extends EntityCo
     private EntityOperator<Object, Object, ?> operator = null;
     private Object rhs = null;
 
-    public <L,R,LL,RR> void init(L lhs, EntityComparisonOperator<LL,RR> operator, R rhs) {
+    public <L,R,LL,RR> EntityExpr(L lhs, EntityComparisonOperator<LL,RR> operator, R rhs) {
         if (lhs == null) {
             throw new IllegalArgumentException("The field name/value cannot be null");
         }
@@ -79,7 +79,7 @@ public class EntityExpr extends EntityCo
         //Debug.logInfo("new EntityExpr internal field=" + lhs + ", value=" + rhs + ", value type=" + (rhs == null ? "null object" : rhs.getClass().getName()), module);
     }
 
-    public void init(EntityCondition lhs, EntityJoinOperator operator, EntityCondition rhs) {
+    public EntityExpr(EntityCondition lhs, EntityJoinOperator operator, EntityCondition rhs) {
         if (lhs == null) {
             throw new IllegalArgumentException("The left EntityCondition argument cannot be null");
         }
@@ -95,12 +95,6 @@ public class EntityExpr extends EntityCo
         this.rhs = rhs;
     }
 
-    public void reset() {
-        this.lhs = null;
-        this.operator = null;
-        this.rhs = null;
-    }
-
     public Object getLhs() {
         return lhs;
     }

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldMap.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldMap.java?rev=1604969&r1=1604968&r2=1604969&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldMap.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldMap.java Tue Jun 24 00:23:32 2014
@@ -32,13 +32,9 @@ import org.ofbiz.entity.util.EntityUtil;
  *
  */
 @SuppressWarnings("serial")
-public class EntityFieldMap extends EntityConditionListBase<EntityExpr> {
+public final class EntityFieldMap extends EntityConditionListBase<EntityExpr> {
 
-    protected Map<String, ? extends Object> fieldMap = null;
-
-    public static <V> List<EntityExpr> makeConditionList(EntityComparisonOperator<?,V> op, V... keysValues) {
-        return makeConditionList(EntityUtil.makeFields(keysValues), op);
-    }
+    protected final Map<String, ? extends Object> fieldMap;
 
     public static <V> List<EntityExpr> makeConditionList(Map<String, V> fieldMap, EntityComparisonOperator<?,V> op) {
         if (fieldMap == null) {
@@ -51,23 +47,13 @@ public class EntityFieldMap extends Enti
         return list;
     }
 
-    public <V> void init(EntityComparisonOperator<?,?> compOp, EntityJoinOperator joinOp, V... keysValues) {
-        super.init(makeConditionList(EntityUtil.makeFields(keysValues), UtilGenerics.<EntityComparisonOperator<String,V>>cast(compOp)), joinOp);
-        Map<String, ? extends Object>  fieldMap = EntityUtil.makeFields(keysValues);
-        this.fieldMap = fieldMap == null ? Collections.<String, Object>emptyMap() : fieldMap;
-        this.operator = joinOp;
+    public <V> EntityFieldMap(EntityComparisonOperator<?,?> compOp, EntityJoinOperator joinOp, V... keysValues) {
+        this(EntityUtil.makeFields(keysValues), UtilGenerics.<EntityComparisonOperator<String,V>>cast(compOp), joinOp);
     }
 
-    public <V> void init(Map<String, V> fieldMap, EntityComparisonOperator<?,?> compOp, EntityJoinOperator joinOp) {
-        super.init(makeConditionList(fieldMap, UtilGenerics.<EntityComparisonOperator<String,V>>cast(compOp)), joinOp);
+    public <V> EntityFieldMap(Map<String, V> fieldMap, EntityComparisonOperator<?,?> compOp, EntityJoinOperator joinOp) {
+        super(makeConditionList(fieldMap, UtilGenerics.<EntityComparisonOperator<String,V>>cast(compOp)), joinOp);
         this.fieldMap = fieldMap == null ? Collections.<String, Object>emptyMap() : fieldMap;
-        this.operator = joinOp;
-    }
-
-    @Override
-    public void reset() {
-        super.reset();
-        this.fieldMap = null;
     }
 
     public Object getField(String name) {

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFunction.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFunction.java?rev=1604969&r1=1604968&r2=1604969&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFunction.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFunction.java Tue Jun 24 00:23:32 2014
@@ -22,9 +22,6 @@ package org.ofbiz.entity.condition;
 import java.util.List;
 import java.util.Map;
 
-import javolution.context.ObjectFactory;
-import javolution.lang.Reusable;
-
 import org.ofbiz.base.util.UtilGenerics;
 import org.ofbiz.entity.Delegator;
 import org.ofbiz.entity.GenericModelException;
@@ -37,28 +34,12 @@ import org.ofbiz.entity.model.ModelField
  *
  */
 @SuppressWarnings("serial")
-public abstract class EntityFunction<T extends Comparable<?>> extends EntityConditionValue implements Reusable {
+public abstract class EntityFunction<T extends Comparable<?>> extends EntityConditionValue {
 
     public static interface Fetcher<T> {
         T getValue(Object value);
     }
 
-    public abstract static class SQLFunctionFactory<T extends Comparable<T>, F extends EntityFunction<T>> extends ObjectFactory<F> {
-        protected abstract void init(F function, Object value);
-
-        protected F createFunction(EntityConditionValue nested) {
-            F ef = object();
-            init(ef, nested);
-            return ef;
-        }
-
-        protected F createFunction(Object value) {
-            F ef = object();
-            init(ef, value);
-            return ef;
-        }
-    }
-
     public static enum SQLFunction {
         LENGTH, TRIM, UPPER, LOWER;
     }
@@ -68,15 +49,15 @@ public abstract class EntityFunction<T e
     public static final int ID_UPPER = SQLFunction.UPPER.ordinal();
     public static final int ID_LOWER = SQLFunction.LOWER.ordinal();
 
-    public static EntityFunction<Integer> LENGTH(EntityConditionValue nested) { return LENGTH.lengthFactory.createFunction(nested); }
-    public static EntityFunction<Integer> LENGTH(Object value) { return LENGTH.lengthFactory.createFunction(value); }
-    public static EntityFunction<String> TRIM(EntityConditionValue nested) { return TRIM.trimFactory.createFunction(nested); }
-    public static EntityFunction<String> TRIM(Object value) { return TRIM.trimFactory.createFunction(value); }
-    public static EntityFunction<String> UPPER(EntityConditionValue nested) { return UPPER.upperFactory.createFunction(nested); }
-    public static EntityFunction<String> UPPER(Object value) { return UPPER.upperFactory.createFunction(value); }
-    public static EntityFunction<String> UPPER_FIELD(String fieldName) { return UPPER.upperFactory.createFunction(EntityFieldValue.makeFieldValue(fieldName)); }
-    public static EntityFunction<String> LOWER(EntityConditionValue nested) { return LOWER.lowerFactory.createFunction(nested); }
-    public static EntityFunction<String> LOWER(Object value) { return LOWER.lowerFactory.createFunction(value); }
+    public static EntityFunction<Integer> LENGTH(EntityConditionValue nested) { return new LENGTH(nested); }
+    public static EntityFunction<Integer> LENGTH(Object value) { return new LENGTH(value); }
+    public static EntityFunction<String> TRIM(EntityConditionValue nested) { return new TRIM(nested); }
+    public static EntityFunction<String> TRIM(Object value) { return new TRIM(value); }
+    public static EntityFunction<String> UPPER(EntityConditionValue nested) { return new UPPER(nested); }
+    public static EntityFunction<String> UPPER(Object value) { return new UPPER(value); }
+    public static EntityFunction<String> UPPER_FIELD(String fieldName) { return new UPPER(EntityFieldValue.makeFieldValue(fieldName)); }
+    public static EntityFunction<String> LOWER(EntityConditionValue nested) { return new LOWER(nested); }
+    public static EntityFunction<String> LOWER(Object value) { return new LOWER(value); }
 
     /**
      * Length() entity function.
@@ -86,20 +67,9 @@ public abstract class EntityFunction<T e
         public static Fetcher<Integer> FETCHER = new Fetcher<Integer>() {
             public Integer getValue(Object value) { return value.toString().length(); }
         };
-        protected static final SQLFunctionFactory<Integer, LENGTH> lengthFactory = new SQLFunctionFactory<Integer, LENGTH>() {
-            @Override
-            protected LENGTH create() {
-                return new LENGTH();
-            }
-
-            @Override
-            protected void init(LENGTH function, Object value) {
-                function.init(value);
-            }
-        };
-        protected LENGTH() {}
-        public void init(Object value) {
-            super.init(FETCHER, SQLFunction.LENGTH, value);
+
+        private LENGTH(Object value) {
+            super(FETCHER, SQLFunction.LENGTH, value);
         }
     }
 
@@ -111,20 +81,9 @@ public abstract class EntityFunction<T e
         public static Fetcher<String> FETCHER = new Fetcher<String>() {
             public String getValue(Object value) { return value.toString().trim(); }
         };
-        protected static final SQLFunctionFactory<String, TRIM> trimFactory = new SQLFunctionFactory<String, TRIM>() {
-            @Override
-            protected TRIM create() {
-                return new TRIM();
-            }
-
-            @Override
-            protected void init(TRIM function, Object value) {
-                function.init(value);
-            }
-        };
-        protected TRIM() {}
-        public void init(Object value) {
-            super.init(FETCHER, SQLFunction.TRIM, value);
+
+        private TRIM(Object value) {
+            super(FETCHER, SQLFunction.TRIM, value);
         }
     }
 
@@ -136,20 +95,9 @@ public abstract class EntityFunction<T e
         public static Fetcher<String> FETCHER = new Fetcher<String>() {
             public String getValue(Object value) { return value.toString().toUpperCase(); }
         };
-        protected static final SQLFunctionFactory<String, UPPER> upperFactory = new SQLFunctionFactory<String, UPPER>() {
-            @Override
-            protected UPPER create() {
-                return new UPPER();
-            }
-
-            @Override
-            protected void init(UPPER function, Object value) {
-                function.init(value);
-            }
-        };
-        protected UPPER() {}
-        public void init(Object value) {
-            super.init(FETCHER, SQLFunction.UPPER, value);
+
+        private UPPER(Object value) {
+            super(FETCHER, SQLFunction.UPPER, value);
         }
     }
 
@@ -161,55 +109,36 @@ public abstract class EntityFunction<T e
         public static Fetcher<String> FETCHER = new Fetcher<String>() {
             public String getValue(Object value) { return value.toString().toLowerCase(); }
         };
-        protected static final SQLFunctionFactory<String, LOWER> lowerFactory = new SQLFunctionFactory<String, LOWER>() {
-            @Override
-            protected LOWER create() {
-                return new LOWER();
-            }
-
-            @Override
-            protected void init(LOWER function, Object value) {
-                function.init(value);
-            }
-        };
-        protected LOWER() {}
-        public void init(Object value) {
-            super.init(FETCHER, SQLFunction.LOWER, value);
+
+        private LOWER(Object value) {
+            super(FETCHER, SQLFunction.LOWER, value);
         }
     }
 
-    protected SQLFunction function;
-    protected EntityConditionValue nested = null;
-    protected Object value = null;
-    protected Fetcher<T> fetcher = null;
-
-    protected EntityFunction() {}
+    protected final SQLFunction function;
+    protected final EntityConditionValue nested;
+    protected final Object value;
+    protected final Fetcher<T> fetcher;
 
     protected EntityFunction(Fetcher<T> fetcher, SQLFunction function, EntityConditionValue nested) {
-        this.init(fetcher, function, nested);
+        this.fetcher = fetcher;
+        this.function = function;
+        this.nested = nested;
+        this.value = null;
     }
 
     protected EntityFunction(Fetcher<T> fetcher, SQLFunction function, Object value) {
-        this.init(fetcher, function, value);
-    }
-
-    public void init(Fetcher<T> fetcher, SQLFunction function, Object value) {
         this.fetcher = fetcher;
         this.function = function;
         if (value instanceof EntityConditionValue) {
             this.nested = (EntityConditionValue) value;
+            this.value = null;
         } else {
+            this.nested = null;
             this.value = value;
         }
     }
 
-    public void reset() {
-        this.function = null;
-        this.nested = null;
-        this.value = null;
-        this.fetcher = null;
-    }
-
     @Override
     public EntityConditionValue freeze() {
         if (nested != null) {

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityWhereString.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityWhereString.java?rev=1604969&r1=1604968&r2=1604969&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityWhereString.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityWhereString.java Tue Jun 24 00:23:32 2014
@@ -40,18 +40,14 @@ import org.ofbiz.entity.model.ModelEntit
  *
  */
 @SuppressWarnings("serial")
-public class EntityWhereString extends EntityCondition {
+public final class EntityWhereString extends EntityCondition {
 
-    protected String sqlString;
+    protected final String sqlString;
 
-    public void init(String sqlString) {
+    public EntityWhereString(String sqlString) {
         this.sqlString = sqlString;
     }
 
-    public void reset() {
-        this.sqlString = null;
-    }
-
     @Override
     public boolean isEmpty() {
         return UtilValidate.isEmpty(sqlString);