mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
Add equals() and hashCode() to AbstractConnection.
This commit is contained in:
@@ -77,4 +77,28 @@ public abstract class AbstractConnection implements Connection {
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (identifier == null) return 0;
|
||||
return identifier.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
// Not equal if null or not a User
|
||||
if (obj == null) return false;
|
||||
if (!(obj instanceof AbstractConnection)) return false;
|
||||
|
||||
// Get identifier
|
||||
String objIdentifier = ((AbstractConnection) obj).identifier;
|
||||
|
||||
// If null, equal only if this identifier is null
|
||||
if (objIdentifier == null) return identifier == null;
|
||||
|
||||
// Otherwise, equal only if strings are identical
|
||||
return objIdentifier.equals(identifier);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user