Added working hashCode() and equals().

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1714 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2002-09-18 21:58:30 +00:00
parent ae1375ca7b
commit 5c2ae9efea
2 changed files with 37 additions and 2 deletions
@@ -1,5 +1,5 @@
//
// $Id: Credentials.java,v 1.8 2002/07/23 05:52:48 mdb Exp $
// $Id: Credentials.java,v 1.9 2002/09/18 21:58:30 mdb Exp $
package com.threerings.presents.net;
@@ -66,6 +66,22 @@ public abstract class Credentials implements Streamable
_username = in.readUTF();
}
// documentation inherited
public int hashCode ()
{
return _username.hashCode();
}
// documentation inherited
public boolean equals (Object other)
{
if (other instanceof Credentials) {
return _username.equals(((Credentials)other)._username);
} else {
return false;
}
}
public String toString ()
{
return "[username=" + _username + "]";
@@ -1,5 +1,5 @@
//
// $Id: UsernamePasswordCreds.java,v 1.7 2002/07/23 05:52:49 mdb Exp $
// $Id: UsernamePasswordCreds.java,v 1.8 2002/09/18 21:58:30 mdb Exp $
package com.threerings.presents.net;
@@ -52,6 +52,25 @@ public class UsernamePasswordCreds extends Credentials
_password = in.readUTF();
}
// documentation inherited
public int hashCode ()
{
return super.hashCode() ^ _password.hashCode();
}
// documentation inherited
public boolean equals (Object other)
{
if (other instanceof UsernamePasswordCredentials) {
UsernamePasswordCredentials upcreds =
(UsernamePasswordCredentials)other;
return super.equals(other) &&
_password.equals(upcreds._password);
} else {
return false;
}
}
public String toString ()
{
return "[username=" + _username + ", password=" + _password + "]";