← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15594: minor change to hashCode/equals calc in Property/Schema

 

------------------------------------------------------------
revno: 15594
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-06-09 11:16:13 +0200
message:
  minor change to hashCode/equals calc in Property/Schema
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Property.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Schema.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/schema/Property.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Property.java	2014-06-09 07:14:11 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Property.java	2014-06-09 09:16:13 +0000
@@ -271,41 +271,32 @@
     }
 
     @Override
-    public boolean equals( Object o )
-    {
-        if ( this == o ) return true;
-        if ( o == null || getClass() != o.getClass() ) return false;
-
-        Property property = (Property) o;
-
-        if ( attribute != property.attribute ) return false;
-        if ( collection != property.collection ) return false;
-        if ( identifiableObject != property.identifiableObject ) return false;
-        if ( nameableObject != property.nameableObject ) return false;
-        if ( collectionName != null ? !collectionName.equals( property.collectionName ) : property.collectionName != null ) return false;
-        if ( description != null ? !description.equals( property.description ) : property.description != null ) return false;
-        if ( getterMethod != null ? !getterMethod.equals( property.getterMethod ) : property.getterMethod != null ) return false;
-        if ( klass != null ? !klass.equals( property.klass ) : property.klass != null ) return false;
-        if ( name != null ? !name.equals( property.name ) : property.name != null ) return false;
-        if ( namespaceURI != null ? !namespaceURI.equals( property.namespaceURI ) : property.namespaceURI != null ) return false;
-
-        return true;
-    }
-
-    @Override
     public int hashCode()
     {
-        int result = klass != null ? klass.hashCode() : 0;
-        result = 31 * result + (getterMethod != null ? getterMethod.hashCode() : 0);
-        result = 31 * result + (name != null ? name.hashCode() : 0);
-        result = 31 * result + (collectionName != null ? collectionName.hashCode() : 0);
-        result = 31 * result + (description != null ? description.hashCode() : 0);
-        result = 31 * result + (namespaceURI != null ? namespaceURI.hashCode() : 0);
-        result = 31 * result + (attribute ? 1 : 0);
-        result = 31 * result + (collection ? 1 : 0);
-        result = 31 * result + (identifiableObject ? 1 : 0);
-        result = 31 * result + (nameableObject ? 1 : 0);
-        return result;
+        return Objects.hashCode( klass, itemKlass, getterMethod, name, collectionName, description, namespaceURI,
+            attribute, simple, collection, identifiableObject, nameableObject );
+    }
+
+    @Override
+    public boolean equals( Object obj )
+    {
+        if ( this == obj )
+        {
+            return true;
+        }
+        if ( obj == null || getClass() != obj.getClass() )
+        {
+            return false;
+        }
+
+        final Property other = (Property) obj;
+
+        return Objects.equal( this.klass, other.klass ) && Objects.equal( this.itemKlass, other.itemKlass )
+            && Objects.equal( this.getterMethod, other.getterMethod ) && Objects.equal( this.name, other.name )
+            && Objects.equal( this.collectionName, other.collectionName ) && Objects.equal( this.description, other.description )
+            && Objects.equal( this.namespaceURI, other.namespaceURI ) && Objects.equal( this.attribute, other.attribute )
+            && Objects.equal( this.simple, other.simple ) && Objects.equal( this.collection, other.collection )
+            && Objects.equal( this.identifiableObject, other.identifiableObject ) && Objects.equal( this.nameableObject, other.nameableObject );
     }
 
     @Override

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Schema.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Schema.java	2014-06-09 07:14:11 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Schema.java	2014-06-09 09:16:13 +0000
@@ -330,7 +330,40 @@
         this.order = order;
     }
 
-    @Override public String toString()
+
+    @Override
+    public int hashCode()
+    {
+        return Objects.hashCode( klass, identifiableObject, nameableObject, singular, plural, namespaceURI, name,
+            collectionName, shareable, apiEndpoint, metadata, authorities, propertyMap, order, authorityMap );
+    }
+
+    @Override
+    public boolean equals( Object obj )
+    {
+        if ( this == obj )
+        {
+            return true;
+        }
+        if ( obj == null || getClass() != obj.getClass() )
+        {
+            return false;
+        }
+
+        final Schema other = (Schema) obj;
+
+        return Objects.equal( this.klass, other.klass ) && Objects.equal( this.identifiableObject, other.identifiableObject )
+            && Objects.equal( this.nameableObject, other.nameableObject ) && Objects.equal( this.singular, other.singular )
+            && Objects.equal( this.plural, other.plural ) && Objects.equal( this.namespaceURI, other.namespaceURI )
+            && Objects.equal( this.name, other.name ) && Objects.equal( this.collectionName, other.collectionName )
+            && Objects.equal( this.shareable, other.shareable ) && Objects.equal( this.apiEndpoint, other.apiEndpoint )
+            && Objects.equal( this.metadata, other.metadata ) && Objects.equal( this.authorities, other.authorities )
+            && Objects.equal( this.propertyMap, other.propertyMap ) && Objects.equal( this.order, other.order )
+            && Objects.equal( this.authorityMap, other.authorityMap );
+    }
+
+    @Override
+    public String toString()
     {
         return Objects.toStringHelper( this )
             .add( "klass", klass )