Rewrote equals() to do without a try/catch statement.

This commit is contained in:
hns 2002-09-05 13:38:15 +00:00
parent d1e173039b
commit 2f74c6cc03
2 changed files with 9 additions and 12 deletions

View file

@ -37,13 +37,12 @@ public final class DbKey implements Key, Serializable {
public boolean equals (Object what) {
if (what == this)
return true;
try {
DbKey k = (DbKey) what;
return (storageName == k.storageName || storageName.equals (k.storageName)) &&
(id == k.id || id.equals (k.id));
} catch (Exception x) {
if (!(what instanceof DbKey))
return false;
}
DbKey k = (DbKey) what;
// storageName is an interned string (by DbMapping, from where we got it)
// so we can compare by using == instead of the equals method.
return storageName == k.storageName && (id == k.id || id.equals (k.id));
}
public int hashCode () {

View file

@ -32,13 +32,11 @@ public final class SyntheticKey implements Key, Serializable {
public boolean equals (Object what) {
if (what == this)
return true;
try {
if (!(what instanceof SyntheticKey))
return false;
SyntheticKey k = (SyntheticKey) what;
return parentKey.equals (k.parentKey) &&
(name == k.name || name.equals (k.name));
} catch (Exception x) {
return false;
}
}
public int hashCode () {