From 0c6c23076f2c09e863c987923c0af54320adb785 Mon Sep 17 00:00:00 2001 From: Henri Yandell Date: Mon, 14 Dec 2009 06:40:42 +0000 Subject: [PATCH] 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 --- .../org/apache/commons/lang3/builder/EqualsBuilder.java | 7 +++++++ .../apache/commons/lang3/builder/EqualsBuilderTest.java | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/src/java/org/apache/commons/lang3/builder/EqualsBuilder.java b/src/java/org/apache/commons/lang3/builder/EqualsBuilder.java index af33dde61..9f590ec5a 100644 --- a/src/java/org/apache/commons/lang3/builder/EqualsBuilder.java +++ b/src/java/org/apache/commons/lang3/builder/EqualsBuilder.java @@ -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; + } } diff --git a/src/test/org/apache/commons/lang3/builder/EqualsBuilderTest.java b/src/test/org/apache/commons/lang3/builder/EqualsBuilderTest.java index 128987190..11e0f7471 100644 --- a/src/test/org/apache/commons/lang3/builder/EqualsBuilderTest.java +++ b/src/test/org/apache/commons/lang3/builder/EqualsBuilderTest.java @@ -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;