dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #17984
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7391: equals/hashCode for attribute/baseNameableObject
------------------------------------------------------------
revno: 7391
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-06-25 23:32:44 +0300
message:
equals/hashCode for attribute/baseNameableObject
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/Attribute.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseNameableObject.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/attribute/Attribute.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/Attribute.java 2012-06-01 11:35:55 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/Attribute.java 2012-06-25 20:32:44 +0000
@@ -87,6 +87,55 @@
this.valueType = valueType;
}
+ @Override
+ public boolean equals( Object o )
+ {
+ if ( this == o ) return true;
+ if ( o == null || getClass() != o.getClass() ) return false;
+ if ( !super.equals( o ) ) return false;
+
+ Attribute attribute = (Attribute) o;
+
+ if ( dataElementAttribute != attribute.dataElementAttribute ) return false;
+ if ( indicatorAttribute != attribute.indicatorAttribute ) return false;
+ if ( mandatory != attribute.mandatory ) return false;
+ if ( organisationUnitAttribute != attribute.organisationUnitAttribute ) return false;
+ if ( userAttribute != attribute.userAttribute ) return false;
+ if ( attributeValues != null ? !attributeValues.equals( attribute.attributeValues ) : attribute.attributeValues != null )
+ return false;
+ if ( dataElementGroupAttribute != null ? !dataElementGroupAttribute.equals( attribute.dataElementGroupAttribute ) : attribute.dataElementGroupAttribute != null )
+ return false;
+ if ( indicatorGroupAttribute != null ? !indicatorGroupAttribute.equals( attribute.indicatorGroupAttribute ) : attribute.indicatorGroupAttribute != null )
+ return false;
+ if ( organisationUnitGroupAttribute != null ? !organisationUnitGroupAttribute.equals( attribute.organisationUnitGroupAttribute ) : attribute.organisationUnitGroupAttribute != null )
+ return false;
+ if ( sortOrder != null ? !sortOrder.equals( attribute.sortOrder ) : attribute.sortOrder != null ) return false;
+ if ( userGroupAttribute != null ? !userGroupAttribute.equals( attribute.userGroupAttribute ) : attribute.userGroupAttribute != null )
+ return false;
+ if ( valueType != null ? !valueType.equals( attribute.valueType ) : attribute.valueType != null ) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = super.hashCode();
+ result = 31 * result + (valueType != null ? valueType.hashCode() : 0);
+ result = 31 * result + (dataElementAttribute ? 1 : 0);
+ result = 31 * result + (dataElementGroupAttribute != null ? dataElementGroupAttribute.hashCode() : 0);
+ result = 31 * result + (indicatorAttribute ? 1 : 0);
+ result = 31 * result + (indicatorGroupAttribute != null ? indicatorGroupAttribute.hashCode() : 0);
+ result = 31 * result + (organisationUnitAttribute ? 1 : 0);
+ result = 31 * result + (organisationUnitGroupAttribute != null ? organisationUnitGroupAttribute.hashCode() : 0);
+ result = 31 * result + (userAttribute ? 1 : 0);
+ result = 31 * result + (userGroupAttribute != null ? userGroupAttribute.hashCode() : 0);
+ result = 31 * result + (mandatory ? 1 : 0);
+ result = 31 * result + (sortOrder != null ? sortOrder.hashCode() : 0);
+ result = 31 * result + (attributeValues != null ? attributeValues.hashCode() : 0);
+ return result;
+ }
+
@JsonProperty
@JsonView( { DetailedView.class, ExportView.class } )
@JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseNameableObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseNameableObject.java 2012-06-06 11:53:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseNameableObject.java 2012-06-25 20:32:44 +0000
@@ -92,6 +92,30 @@
this.description = description;
}
+ @Override
+ public boolean equals( Object o )
+ {
+ if ( this == o ) return true;
+ if ( o == null || getClass() != o.getClass() ) return false;
+ if ( !super.equals( o ) ) return false;
+
+ BaseNameableObject that = (BaseNameableObject) o;
+
+ if ( description != null ? !description.equals( that.description ) : that.description != null ) return false;
+ if ( shortName != null ? !shortName.equals( that.shortName ) : that.shortName != null ) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = super.hashCode();
+ result = 31 * result + (shortName != null ? shortName.hashCode() : 0);
+ result = 31 * result + (description != null ? description.hashCode() : 0);
+ return result;
+ }
+
public String getAlternativeName()
{
return alternativeName;