Rewrote equals() to do without a try/catch statement.
This commit is contained in:
parent
d1e173039b
commit
2f74c6cc03
2 changed files with 9 additions and 12 deletions
|
@ -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 () {
|
||||
|
|
|
@ -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 () {
|
||||
|
|
Loading…
Add table
Reference in a new issue