dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16208
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6106: Temp fix for User hashcode/equals
------------------------------------------------------------
revno: 6106
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-02-24 12:25:04 +0100
message:
Temp fix for User hashcode/equals
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.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/user/User.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java 2012-01-12 06:36:54 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java 2012-02-24 11:25:04 +0000
@@ -90,49 +90,101 @@
// -------------------------------------------------------------------------
@Override
+ public String toString()
+ {
+ return "[" + surname + " " + firstName + "]";
+ }
+
+ // -------------------------------------------------------------------------
+ // Logic
+ // -------------------------------------------------------------------------
+
+ @Override
public int hashCode()
{
final int prime = 31;
+
int result = 1;
-
- result = result * prime + surname.hashCode();
- result = result * prime + firstName.hashCode();
-
+
+ result = prime * result + ( ( email == null) ? 0 : email.hashCode() );
+ result = prime * result + ( ( firstName == null) ? 0 : firstName.hashCode() );
+ result = prime * result + ( ( phoneNumber == null) ? 0 : phoneNumber.hashCode() );
+ result = prime * result + ( ( surname == null) ? 0 : surname.hashCode() );
+
return result;
}
+ // TODO fix, users might very well have the same name, should use credentials
+
@Override
- public boolean equals( Object o )
+ public boolean equals( Object object )
{
- if ( this == o )
+ if ( this == object )
{
return true;
}
-
- if ( o == null )
- {
- return false;
- }
-
- if ( !(o instanceof User) )
- {
- return false;
- }
-
- final User other = (User) o;
-
- return surname.equals( other.getSurname() ) && firstName.equals( other.getFirstName() );
- }
-
- @Override
- public String toString()
- {
- return "[" + surname + " " + firstName + "]";
- }
-
- // -------------------------------------------------------------------------
- // Logic
- // -------------------------------------------------------------------------
+ if ( object == null )
+ {
+ return false;
+ }
+
+ if ( getClass() != object.getClass() )
+ {
+ return false;
+ }
+
+ User other = (User) object;
+
+ if ( firstName == null )
+ {
+ if ( other.firstName != null )
+ {
+ return false;
+ }
+ }
+ else if ( !firstName.equals( other.firstName ) )
+ {
+ return false;
+ }
+
+ if ( surname == null )
+ {
+ if ( other.surname != null )
+ {
+ return false;
+ }
+ }
+ else if ( !surname.equals( other.surname ) )
+ {
+ return false;
+ }
+
+ if ( email == null )
+ {
+ if ( other.email != null )
+ {
+ return false;
+ }
+ }
+ else if ( !email.equals( other.email ) )
+ {
+ return false;
+ }
+
+ if ( phoneNumber == null )
+ {
+ if ( other.phoneNumber != null )
+ {
+ return false;
+ }
+ }
+ else if ( !phoneNumber.equals( other.phoneNumber ) )
+ {
+ return false;
+ }
+
+ return true;
+ }
public void addOrganisationUnit( OrganisationUnit unit )
{