Skip to content

Commit

Permalink
Fixes #19 - equals() and hashCode() symmetry
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfl committed Sep 28, 2011
1 parent 24a71fd commit 845cb5a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion core/src/java/org/jdom2/filter/AndFilter.java
Expand Up @@ -111,7 +111,7 @@ public boolean equals(Object obj) {

@Override
public int hashCode() {
return (31 * left.hashCode()) + right.hashCode();
return (left.hashCode()) ^ right.hashCode();
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion core/src/java/org/jdom2/filter/OrFilter.java
Expand Up @@ -111,7 +111,7 @@ public boolean equals(Object obj) {

@Override
public int hashCode() {
return (31 * left.hashCode()) + right.hashCode();
return ~(left.hashCode()) ^ right.hashCode();
}

@Override
Expand Down
Expand Up @@ -263,18 +263,15 @@ protected void exercise(Filter ef, Parent parent, CallBack callback) {
exerciseCore(nf.or(nf.negate()), parent, new TrueCallBack());
exerciseCore(nf.and(nf.negate()), parent, new FalseCallBack());

/*
* Fix Issue #19 before enabling the following!
*

Filter afor = UnitTestUtil.deSerialize(af).or(nf);
Filter bfor = nf.or(af);
assertFilterEquals(afor, bfor);

Filter afand = UnitTestUtil.deSerialize(af).and(nf);
Filter bfand = nf.and(af);
assertFilterEquals(afand, bfand);
*/

}
}

Expand Down

0 comments on commit 845cb5a

Please sign in to comment.