Added instanceof checks to equals().

git-svn-id: https://samskivert.googlecode.com/svn/trunk@2716 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
samskivert
2010-02-09 20:25:01 +00:00
parent c9a12f1b3e
commit 654596a619
3 changed files with 5 additions and 5 deletions
@@ -503,7 +503,7 @@ public class RuntimeAdjust
@Override public boolean equals (Object other)
{
return _name.equals(((Adjust)other)._name);
return (other instanceof Adjust) && _name.equals(((Adjust)other)._name);
}
@Override public int hashCode ()
+1 -1
View File
@@ -585,7 +585,7 @@ public class ConfigUtil
}
@Override public boolean equals (Object other) {
return _package.equals(((PropRecord)other)._package);
return (other instanceof PropRecord) && _package.equals(((PropRecord)other)._package);
}
@Override public String toString () {
+3 -3
View File
@@ -63,10 +63,10 @@ public class KeyValue<K extends Comparable<? super K>,V>
}
@Override
@SuppressWarnings("unchecked") // documentation inherited
@SuppressWarnings("unchecked")
public boolean equals (Object other)
{
return key.equals(((KeyValue<K,V>)other).key);
return (other instanceof KeyValue<?,?>) && key.equals(((KeyValue<K,V>)other).key);
}
@Override
@@ -75,7 +75,7 @@ public class KeyValue<K extends Comparable<? super K>,V>
return key.hashCode();
}
// documentation inherited
// from interface Comparable<KeyValue<K,V>>
public int compareTo (KeyValue<K,V> other)
{
return key.compareTo(other.key);