------------------------------------------------------------ revno: 15410 committer: Morten Olav Hansen <morte...@gmail.com> branch nick: dhis2 timestamp: Mon 2014-05-26 14:01:56 +0200 message: hashCode/equals fixes to ProgramStageDataElement and ProgramTrackedEntityAttribute modified: dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElement.java dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramTrackedEntityAttribute.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/program/ProgramStageDataElement.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElement.java 2014-05-23 12:36:33 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElement.java 2014-05-26 12:01:56 +0000 @@ -192,33 +192,34 @@ // ------------------------------------------------------------------------- @Override + public boolean equals( Object o ) + { + if ( this == o ) return true; + if ( o == null || getClass() != o.getClass() ) return false; + + ProgramStageDataElement that = (ProgramStageDataElement) o; + + if ( compulsory != that.compulsory ) return false; + if ( allowDateInFuture != null ? !allowDateInFuture.equals( that.allowDateInFuture ) : that.allowDateInFuture != null ) + return false; + if ( allowProvidedElsewhere != null ? !allowProvidedElsewhere.equals( that.allowProvidedElsewhere ) : that.allowProvidedElsewhere != null ) + return false; + if ( dataElement != null ? !dataElement.equals( that.dataElement ) : that.dataElement != null ) return false; + if ( displayInReports != null ? !displayInReports.equals( that.displayInReports ) : that.displayInReports != null ) return false; + if ( programStage != null ? !programStage.equals( that.programStage ) : that.programStage != null ) return false; + + return true; + } + + @Override public int hashCode() { - final int prime = 31; - int result = 1; - - result = result * prime + programStage.hashCode(); - result = result * prime + dataElement.hashCode(); - + int result = programStage != null ? programStage.hashCode() : 0; + result = 31 * result + (dataElement != null ? dataElement.hashCode() : 0); + result = 31 * result + (compulsory ? 1 : 0); + result = 31 * result + (allowProvidedElsewhere != null ? allowProvidedElsewhere.hashCode() : 0); + result = 31 * result + (displayInReports != null ? displayInReports.hashCode() : 0); + result = 31 * result + (allowDateInFuture != null ? allowDateInFuture.hashCode() : 0); return result; } - - @Override - public boolean equals( Object object ) - { - if ( object == null ) - { - return false; - } - - if ( getClass() != object.getClass() ) - { - return false; - } - - final ProgramStageDataElement other = (ProgramStageDataElement) object; - - return dataElement.getId() == other.getDataElement().getId() - && programStage.getId() == other.getProgramStage().getId(); - } } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramTrackedEntityAttribute.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramTrackedEntityAttribute.java 2014-05-23 15:28:46 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramTrackedEntityAttribute.java 2014-05-26 12:01:56 +0000 @@ -44,7 +44,6 @@ /** * @author Chau Thu Tran - * @version $ ProgramTrackedEntityAttribute.java Jan 7, 2014 9:16:05 AM $ */ @JacksonXmlRootElement(localName = "programTrackedEntityAttribute", namespace = DxfNamespaces.DXF_2_0) public class ProgramTrackedEntityAttribute @@ -91,34 +90,31 @@ // ------------------------------------------------------------------------- @Override + public boolean equals( Object o ) + { + if ( this == o ) return true; + if ( o == null || getClass() != o.getClass() ) return false; + + ProgramTrackedEntityAttribute that = (ProgramTrackedEntityAttribute) o; + + if ( displayInList != that.displayInList ) return false; + if ( id != that.id ) return false; + if ( attribute != null ? !attribute.equals( that.attribute ) : that.attribute != null ) return false; + if ( mandatory != null ? !mandatory.equals( that.mandatory ) : that.mandatory != null ) return false; + + return true; + } + + @Override public int hashCode() { - final int prime = 31; - int result = 1; - - result = result * prime + (attribute != null ? attribute.hashCode() : 1); - result = result * prime + sortOrder; - + int result = id; + result = 31 * result + (attribute != null ? attribute.hashCode() : 0); + result = 31 * result + (displayInList ? 1 : 0); + result = 31 * result + (mandatory != null ? mandatory.hashCode() : 0); return result; } - @Override - public boolean equals( Object object ) - { - if ( object == null ) - { - return false; - } - - if ( getClass() != object.getClass() ) - { - return false; - } - - final ProgramTrackedEntityAttribute other = (ProgramTrackedEntityAttribute) object; - - return attribute != null && attribute.equals( other.getAttribute() ) && sortOrder.equals( other.getSortOrder() ); - } // ------------------------------------------------------------------------- // Getters && Setters
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : dhis2-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp