← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7410: reverted equals/hashCode for expression

 

------------------------------------------------------------
revno: 7410
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-06-27 08:46:37 +0300
message:
  reverted equals/hashCode for expression
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/Expression.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/Expression.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/Expression.java	2012-06-25 20:14:42 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/Expression.java	2012-06-27 05:46:37 +0000
@@ -136,20 +136,48 @@
     // -------------------------------------------------------------------------
 
     @Override
-    public boolean equals( Object o )
+    public boolean equals( Object obj )
     {
-        if ( this == o ) return true;
-        if ( o == null || getClass() != o.getClass() ) return false;
-
-        Expression that = (Expression) o;
-
-        if ( id != that.id ) return false;
-        if ( dataElementsInExpression != null ? !dataElementsInExpression.equals( that.dataElementsInExpression ) : that.dataElementsInExpression != null )
-            return false;
-        if ( description != null ? !description.equals( that.description ) : that.description != null ) return false;
-        if ( expression != null ? !expression.equals( that.expression ) : that.expression != null ) return false;
-        if ( optionCombosInExpression != null ? !optionCombosInExpression.equals( that.optionCombosInExpression ) : that.optionCombosInExpression != null )
-            return false;
+        if ( this == obj )
+        {
+            return true;
+        }
+
+        if ( obj == null )
+        {
+            return false;
+        }
+
+        if ( getClass() != obj.getClass() )
+        {
+            return false;
+        }
+
+        final Expression other = (Expression) obj;
+
+        if ( description == null )
+        {
+            if ( other.description != null )
+            {
+                return false;
+            }
+        }
+        else if ( !description.equals( other.description ) )
+        {
+            return false;
+        }
+
+        if ( expression == null )
+        {
+            if ( other.expression != null )
+            {
+                return false;
+            }
+        }
+        else if ( !expression.equals( other.expression ) )
+        {
+            return false;
+        }
 
         return true;
     }
@@ -157,11 +185,10 @@
     @Override
     public int hashCode()
     {
-        int result = id;
-        result = 31 * result + (expression != null ? expression.hashCode() : 0);
-        result = 31 * result + (description != null ? description.hashCode() : 0);
-        result = 31 * result + (dataElementsInExpression != null ? dataElementsInExpression.hashCode() : 0);
-        result = 31 * result + (optionCombosInExpression != null ? optionCombosInExpression.hashCode() : 0);
+        final int PRIME = 31;
+        int result = 1;
+        result = PRIME * result + ((description == null) ? 0 : description.hashCode());
+        result = PRIME * result + ((expression == null) ? 0 : expression.hashCode());
 
         return result;
     }