diff --git a/pmd/etc/changelog.txt b/pmd/etc/changelog.txt index fc6e6bc163..44a64501f4 100644 --- a/pmd/etc/changelog.txt +++ b/pmd/etc/changelog.txt @@ -13,7 +13,7 @@ Fixed bug which caused MissingSerialVersionUID to trigger on all interfaces that Modified NullAssignmentRule to catch null assignments in ternary expressions. Added two new node types - ASTCatchStatement and ASTFinallyStatement. Modified rule XML definition; it no longer includes a symboltable attribute. -Harden equality of AbstractRule objects (needed for the Eclipse plugin features) +Harden equality of AbstractRule and RuleSet objects (needed for the Eclipse plugin features) May 10, 2005 - 3.1: New rules: SimplifyStartsWith, UnnecessaryParentheses, CollapsibleIfStatements, UseAssertEqualsInsteadOfAssertTrue, UseAssertSameInsteadOfAssertTrue, UseStringBufferForStringAppends, SimplifyConditional, SingularField diff --git a/pmd/src/net/sourceforge/pmd/RuleSet.java b/pmd/src/net/sourceforge/pmd/RuleSet.java index 780a1af2f6..408558fe60 100644 --- a/pmd/src/net/sourceforge/pmd/RuleSet.java +++ b/pmd/src/net/sourceforge/pmd/RuleSet.java @@ -124,4 +124,27 @@ public class RuleSet { public void setDescription(String description) { this.description = description; } + + /** + * @see java.lang.Object#equals(java.lang.Object) + */ + public boolean equals(Object o) { + if ((o == null) || !(o instanceof RuleSet)) { + return false; // Trivial + } + + if (this == o) { + return true; // Basic equality + } + + RuleSet ruleSet = (RuleSet) o; + return this.getName().equals(ruleSet.getName()) && this.getRules().equals(ruleSet.getRules()); + } + + /** + * @see java.lang.Object#hashCode() + */ + public int hashCode() { + return this.getName().hashCode() + 13*this.getRules().hashCode(); + } }