Adding a reset() method to EqualsBuilder. LANG-466

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@890196 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Henri Yandell 2009-12-14 06:40:42 +00:00
parent 2851806365
commit 0c6c23076f
2 changed files with 16 additions and 0 deletions

View File

@ -840,4 +840,11 @@ public class EqualsBuilder {
protected void setEquals(boolean isEquals) {
this.isEquals = isEquals;
}
/**
* Reset the EqualsBuilder so you can use the same object again
*/
public void reset() {
this.isEquals = true;
}
}

View File

@ -391,6 +391,15 @@ public class EqualsBuilderTest extends TestCase {
equalsBuilder.setEquals(false);
assertFalse(equalsBuilder.isEquals());
}
public void testReset() {
EqualsBuilder equalsBuilder = new EqualsBuilder();
assertTrue(equalsBuilder.isEquals());
equalsBuilder.setEquals(false);
assertFalse(equalsBuilder.isEquals());
equalsBuilder.reset();
assertTrue(equalsBuilder.isEquals());
}
public void testBoolean() {
boolean o1 = true;