Harden equality of RuleSet objects

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@3554 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Philippe Herlin
2005-06-09 22:21:39 +00:00
parent 25f451277c
commit 17f4c44189
2 changed files with 24 additions and 1 deletions

View File

@ -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

View File

@ -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();
}
}