svn commit: r814512 - in /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition: EntityComparisonOperator.java EntityOperator.java

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

svn commit: r814512 - in /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition: EntityComparisonOperator.java EntityOperator.java

doogie-3
Author: doogie
Date: Mon Sep 14 07:54:41 2009
New Revision: 814512

URL: http://svn.apache.org/viewvc?rev=814512&view=rev
Log:
Remove the compare method from the base class, and make it abstract.

Modified:
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityComparisonOperator.java
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityOperator.java

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityComparisonOperator.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityComparisonOperator.java?rev=814512&r1=814511&r2=814512&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityComparisonOperator.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityComparisonOperator.java Mon Sep 14 07:54:41 2009
@@ -41,7 +41,7 @@
 /**
  * Encapsulates operations between entities and entity fields. This is a immutable class.
  */
-public class EntityComparisonOperator<L, R> extends EntityOperator<L, R, Boolean> {
+public abstract class EntityComparisonOperator<L, R> extends EntityOperator<L, R, Boolean> {
 
     public static final String module = EntityComparisonOperator.class.getName();
 
@@ -129,9 +129,7 @@
         }
     }
 
-    public <T> boolean compare(Comparable<T> lhs, T rhs) {
-        throw new UnsupportedOperationException(codeString);
-    }
+    public abstract boolean compare(L lhs, R rhs);
 
     public Boolean eval(GenericDelegator delegator, Map<String, ? extends Object> map, Object lhs, Object rhs) {
         return Boolean.valueOf(mapMatches(delegator, map, lhs, rhs));
@@ -158,7 +156,7 @@
         }
 
         if (leftValue == WILDCARD || rightValue == WILDCARD) return true;
-        return compare((Comparable) leftValue, rightValue);
+        return compare((L) leftValue, (R) rightValue);
     }
 
     @Override

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityOperator.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityOperator.java?rev=814512&r1=814511&r2=814512&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityOperator.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityOperator.java Mon Sep 14 07:54:41 2009
@@ -109,47 +109,50 @@
     static { register("notEqual", NOT_EQUAL); }
     public static final EntityComparisonOperator LESS_THAN = new ComparableEntityComparisonOperator(ID_LESS_THAN, "<") {
         @Override
-        public <T> boolean compare(Comparable<T> lhs, T rhs) { return EntityComparisonOperator.compareLessThan(lhs, rhs); }
+        public boolean compare(Comparable lhs, Object rhs) { return EntityComparisonOperator.compareLessThan(lhs, rhs); }
     };
     static { register("less", LESS_THAN); }
     static { register("less-than", LESS_THAN); }
     static { register("lessThan", LESS_THAN); }
     public static final EntityComparisonOperator GREATER_THAN = new ComparableEntityComparisonOperator(ID_GREATER_THAN, ">") {
         @Override
-        public <T> boolean compare(Comparable<T> lhs, T rhs) { return EntityComparisonOperator.compareGreaterThan(lhs, rhs); }
+        public boolean compare(Comparable lhs, Object rhs) { return EntityComparisonOperator.compareGreaterThan(lhs, rhs); }
     };
     static { register("greater", GREATER_THAN); }
     static { register("greater-than", GREATER_THAN); }
     static { register("greaterThan", GREATER_THAN); }
     public static final EntityComparisonOperator LESS_THAN_EQUAL_TO = new ComparableEntityComparisonOperator(ID_LESS_THAN_EQUAL_TO, "<=") {
         @Override
-        public <T> boolean compare(Comparable<T> lhs, T rhs) { return EntityComparisonOperator.compareLessThanEqualTo(lhs, rhs); }
+        public boolean compare(Comparable lhs, Object rhs) { return EntityComparisonOperator.compareLessThanEqualTo(lhs, rhs); }
     };
     static { register("less-equals", LESS_THAN_EQUAL_TO); }
     static { register("less-than-equal-to", LESS_THAN_EQUAL_TO); }
     static { register("lessThanEqualTo", LESS_THAN_EQUAL_TO); }
     public static final EntityComparisonOperator GREATER_THAN_EQUAL_TO = new ComparableEntityComparisonOperator(ID_GREATER_THAN_EQUAL_TO, ">=") {
         @Override
-        public <T> boolean compare(Comparable<T> lhs, T rhs) { return EntityComparisonOperator.compareGreaterThanEqualTo(lhs, rhs); }
+        public boolean compare(Comparable lhs, Object rhs) { return EntityComparisonOperator.compareGreaterThanEqualTo(lhs, rhs); }
     };
     static { register("greater-equals", GREATER_THAN_EQUAL_TO); }
     static { register("greater-than-equal-to", GREATER_THAN_EQUAL_TO); }
     static { register("greaterThanEqualTo", GREATER_THAN_EQUAL_TO); }
     public static final EntityComparisonOperator IN = new CollectionEntityComparisonOperator(ID_IN, "IN") {
         @Override
-        public <T> boolean compare(Comparable<T> lhs, T rhs) { return EntityComparisonOperator.compareIn(lhs, rhs); }
+        public boolean compare(Comparable lhs, Collection<Comparable> rhs) { return EntityComparisonOperator.compareIn(lhs, rhs); }
         @Override
         protected void makeRHSWhereStringValue(ModelEntity entity, List<EntityConditionParam> entityConditionParams, StringBuilder sb, ModelField field, Object rhs, DatasourceInfo datasourceInfo) { appendRHSList(entityConditionParams, sb, field, rhs); }
     };
     static { register("in", IN); }
     public static final EntityComparisonOperator BETWEEN = new CollectionEntityComparisonOperator(ID_BETWEEN, "BETWEEN") {
         @Override
-        public <T> boolean compare(Comparable<T> lhs, T rhs) { return EntityComparisonOperator.compareIn(lhs, rhs); }
+        public boolean compare(Comparable lhs, Collection<Comparable> rhs) { return EntityComparisonOperator.compareIn(lhs, rhs); }
         @Override
         protected void makeRHSWhereStringValue(ModelEntity entity, List<EntityConditionParam> entityConditionParams, StringBuilder sb, ModelField field, Object rhs, DatasourceInfo datasourceInfo) { appendRHSBetweenList(entityConditionParams, sb, field, rhs); }
     };
     static { register("between", BETWEEN); }
-    public static final EntityComparisonOperator NOT = new EntityComparisonOperator<Object, EntityCondition>(ID_NOT, "NOT");
+    public static final EntityComparisonOperator NOT = new EntityComparisonOperator<Object, EntityCondition>(ID_NOT, "NOT") {
+        @Override
+        public boolean compare(Object lhs, EntityCondition rhs) { throw new UnsupportedOperationException(); }
+    };
     static { register("not", NOT); }
     public static final EntityJoinOperator AND = new EntityJoinOperator(ID_AND, "AND", false);
     static { register("and", AND); }
@@ -162,12 +165,12 @@
     static { register("like", LIKE); }
     public static final EntityComparisonOperator NOT_LIKE = new ComparableEntityComparisonOperator(ID_NOT_LIKE, "NOT LIKE") {
         @Override
-        public <T> boolean compare(Comparable<T> lhs, T rhs) { return !EntityComparisonOperator.compareLike(lhs, rhs); }
+        public boolean compare(Comparable lhs, Object rhs) { return !EntityComparisonOperator.compareLike(lhs, rhs); }
     };
     static { register("not-like", NOT_LIKE); }
     public static final EntityComparisonOperator NOT_IN = new CollectionEntityComparisonOperator(ID_NOT_IN, "NOT IN") {
         @Override
-        public <T> boolean compare(Comparable<T> lhs, T rhs) { return !EntityComparisonOperator.compareIn(lhs, rhs); }
+        public boolean compare(Comparable lhs, Collection<Comparable> rhs) { return !EntityComparisonOperator.compareIn(lhs, rhs); }
         @Override
         protected void makeRHSWhereStringValue(ModelEntity entity, List<EntityConditionParam> entityConditionParams, StringBuilder sb, ModelField field, Object rhs, DatasourceInfo datasourceInfo) { appendRHSList(entityConditionParams, sb, field, rhs); }
     };