From 4afb9fabd9e7580381e31018e4d89a3d75b80731 Mon Sep 17 00:00:00 2001 From: Tom Copeland Date: Mon, 30 Jun 2003 15:15:49 +0000 Subject: [PATCH] Added type check to equals() git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@2049 51baf565-9d33-0410-a72c-fc3788e3496d --- pmd/src/net/sourceforge/pmd/AbstractRule.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pmd/src/net/sourceforge/pmd/AbstractRule.java b/pmd/src/net/sourceforge/pmd/AbstractRule.java index 1d0a083467..4d02936fc4 100644 --- a/pmd/src/net/sourceforge/pmd/AbstractRule.java +++ b/pmd/src/net/sourceforge/pmd/AbstractRule.java @@ -73,8 +73,10 @@ public abstract class AbstractRule extends JavaParserVisitorAdapter implements R } public boolean equals(Object o) { - Rule r = (Rule) o; - return r.getName().equals(getName()); + if (!(o instanceof Rule)) { + return false; + } + return ((Rule)o).getName().equals(getName()); } public int hashCode() {