From 4b718f6e5a90a0922373bd1d2452d418fe6bdf54 Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Sat, 8 Feb 2014 04:35:17 +0000 Subject: [PATCH] Add APIs MutableBoolean setTrue() and setFalse() git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1565915 13f79535-47bb-0310-9956-ffa450edef68 --- src/changes/changes.xml | 1 + .../commons/lang3/mutable/MutableBoolean.java | 18 ++++++++++++++++++ .../lang3/mutable/MutableBooleanTest.java | 6 ++++++ 3 files changed, 25 insertions(+) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 7f7032a9f..c5c310b8c 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -22,6 +22,7 @@ + Add APIs MutableBoolean setTrue() and setFalse() ConstantInitializerTest fails when building with IBM JDK 7 Add SerializationUtils.roundtrip(T extends Serializable) to serialize then deserialize org.apache.commons.lang3.reflect.FieldUtils.removeFinalModifier(Field) does not clean up after itself diff --git a/src/main/java/org/apache/commons/lang3/mutable/MutableBoolean.java b/src/main/java/org/apache/commons/lang3/mutable/MutableBoolean.java index a07a055dc..1c0d05058 100644 --- a/src/main/java/org/apache/commons/lang3/mutable/MutableBoolean.java +++ b/src/main/java/org/apache/commons/lang3/mutable/MutableBoolean.java @@ -88,6 +88,24 @@ public class MutableBoolean implements Mutable, Serializable, Comparabl this.value = value; } + /** + * Sets the value to true. + * + * @since 3.3 + */ + public void setFalse() { + this.value = false; + } + + /** + * Sets the value to false. + * + * @since 3.3 + */ + public void setTrue() { + this.value = true; + } + /** * Sets the value from any Boolean instance. * diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableBooleanTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableBooleanTest.java index 5109f8fbc..8e3e3145a 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableBooleanTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableBooleanTest.java @@ -105,6 +105,12 @@ public class MutableBooleanTest { mutBool.setValue(true); assertTrue(mutBool.booleanValue()); + mutBool.setFalse(); + assertFalse(mutBool.booleanValue()); + + mutBool.setTrue(); + assertTrue(mutBool.booleanValue()); + } @Test(expected=NullPointerException.class)