mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
Ticket #269: Added hashcode functions for MySQLUSer and MySQLConnection.
This commit is contained in:
@@ -91,7 +91,6 @@ public class MySQLConnection implements Connection {
|
||||
* @param connection
|
||||
*/
|
||||
public void initNew(Connection connection) {
|
||||
configuration = connection.getConfiguration();
|
||||
this.connection.setConnection_name(connection.getIdentifier());
|
||||
this.configuration = connection.getConfiguration();
|
||||
}
|
||||
@@ -150,7 +149,19 @@ public class MySQLConnection implements Connection {
|
||||
public boolean equals(Object other) {
|
||||
if(!(other instanceof MySQLConnection))
|
||||
return false;
|
||||
return ((MySQLConnection)other).getConnectionID() == this.getConnectionID();
|
||||
boolean idsAreEqual = ((MySQLConnection)other).getConnectionID() == this.getConnectionID();
|
||||
// they are both new, check if they have the same name
|
||||
if(idsAreEqual && this.getConnectionID() == 0)
|
||||
return this.getIdentifier().equals(((MySQLConnection)other).getIdentifier());
|
||||
return idsAreEqual;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 73 * hash + getConnectionID();
|
||||
hash = 73 * hash + getIdentifier().hashCode();
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -207,6 +207,18 @@ public class MySQLUser implements User {
|
||||
public boolean equals(Object other) {
|
||||
if(!(other instanceof MySQLUser))
|
||||
return false;
|
||||
return ((MySQLUser)other).getUserID() == this.getUserID();
|
||||
boolean idsAreEqual = ((MySQLUser)other).getUserID() == this.getUserID();
|
||||
// they are both new, check if they have the same name
|
||||
if(idsAreEqual && this.getUserID() == 0)
|
||||
return this.getUsername().equals(((MySQLUser)other).getUsername());
|
||||
return idsAreEqual;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 73 * hash + getUserID();
|
||||
hash = 73 * hash + getUsername().hashCode();
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user