You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2016/06/02 10:46:17 UTC
[lang] LANG-1189 Add
getAndIncrement/getAndDecrement/getAndAdd/incrementAndGet/decrementAndGet/addAndGet
in Mutable* classes
Repository: commons-lang
Updated Branches:
refs/heads/master 17d6f2163 -> e47426366
LANG-1189 Add
getAndIncrement/getAndDecrement/getAndAdd/incrementAndGet/decrementAndGet/addAndGet
in Mutable* classes
Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/e4742636
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/e4742636
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/e4742636
Branch: refs/heads/master
Commit: e474263669a6bfb5ec56dca742b8e220f02fbe1d
Parents: 17d6f21
Author: Sebb <se...@apache.org>
Authored: Thu Jun 2 11:46:11 2016 +0100
Committer: Sebb <se...@apache.org>
Committed: Thu Jun 2 11:46:11 2016 +0100
----------------------------------------------------------------------
src/changes/changes.xml | 25 +++++
.../commons/lang3/mutable/MutableByte.java | 98 ++++++++++++++++++++
.../commons/lang3/mutable/MutableDouble.java | 98 ++++++++++++++++++++
.../commons/lang3/mutable/MutableFloat.java | 98 ++++++++++++++++++++
.../commons/lang3/mutable/MutableInt.java | 98 ++++++++++++++++++++
.../commons/lang3/mutable/MutableLong.java | 98 ++++++++++++++++++++
.../commons/lang3/mutable/MutableShort.java | 98 ++++++++++++++++++++
.../commons/lang3/mutable/MutableByteTest.java | 76 +++++++++++++++
.../lang3/mutable/MutableDoubleTest.java | 76 +++++++++++++++
.../commons/lang3/mutable/MutableFloatTest.java | 76 +++++++++++++++
.../commons/lang3/mutable/MutableIntTest.java | 76 +++++++++++++++
.../commons/lang3/mutable/MutableLongTest.java | 76 +++++++++++++++
.../commons/lang3/mutable/MutableShortTest.java | 76 +++++++++++++++
13 files changed, 1069 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/e4742636/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index d1785b7..c35e734 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -15,6 +15,30 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
+
+<!--
+This file is also used by the maven-changes-plugin to generate the release notes.
+Useful ways of finding items to add to this file are:
+
+1. Add items when you fix a bug or add a feature (this makes the
+release process easy :-).
+
+2. Do a JIRA search for tickets closed since the previous release.
+
+3. Use the report generated by the maven-changelog-plugin to see all
+SVN commits. TBA how to use this with SVN.
+
+To generate the release notes from this file:
+
+mvn changes:announcement-generate -Prelease-notes [-Dchanges.version=nnn]
+
+then tweak the formatting if necessary
+and commit
+
+The <action> type attribute can be add,update,fix,remove.
+-->
+
+
<document>
<properties>
<title>Apache Commons Lang Changes</title>
@@ -22,6 +46,7 @@
<body>
<release version="3.5" date="tba" description="tba">
+ <action issue="LANG-1189" type="add" dev="sebb" due-to="haiyang li / Matthew Bartenschlag ">Add getAndIncrement/getAndDecrement/getAndAdd/incrementAndGet/decrementAndGet/addAndGet in Mutable* classes</action>
<action issue="LANG-1240" type="update" dev="pschumacher" due-to="zhanhb">Optimize BitField constructor implementation</action>
<action issue="LANG-1206" type="update" dev="pschumacher" due-to="Mohammed Alfallaj">Improve CharSetUtils.squeeze() performance</action>
<action issue="LANG-1225" type="add" dev="pschumacher" due-to="Caleb Cushing">Add RandomStringUtils#randomGraph and #randomPrint which match corresponding regular expression class</action>
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/e4742636/src/main/java/org/apache/commons/lang3/mutable/MutableByte.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/mutable/MutableByte.java b/src/main/java/org/apache/commons/lang3/mutable/MutableByte.java
index 80edf3a..b6674d8 100644
--- a/src/main/java/org/apache/commons/lang3/mutable/MutableByte.java
+++ b/src/main/java/org/apache/commons/lang3/mutable/MutableByte.java
@@ -120,6 +120,29 @@ public class MutableByte extends Number implements Comparable<MutableByte>, Muta
}
/**
+ * Increments this instance's value by 1; this method returns the value associated with the instance
+ * immediately prior to the increment operation. This method is not thread safe.
+ *
+ * @return the value associated with the instance before it was incremented
+ */
+ public byte getAndIncrement() {
+ byte last = value;
+ value++;
+ return last;
+ }
+
+ /**
+ * Increments this instance's value by 1; this method returns the value associated with the instance
+ * immediately after the increment operation. This method is not thread safe.
+ *
+ * @return the value associated with the instance after it is incremented
+ */
+ public byte incrementAndGet() {
+ value++;
+ return value;
+ }
+
+ /**
* Decrements the value.
*
* @since Commons Lang 2.2
@@ -128,6 +151,29 @@ public class MutableByte extends Number implements Comparable<MutableByte>, Muta
value--;
}
+ /**
+ * Decrements this instance's value by 1; this method returns the value associated with the instance
+ * immediately prior to the decrement operation. This method is not thread safe.
+ *
+ * @return the value associated with the instance before it was decremented
+ */
+ public byte getAndDecrement() {
+ byte last = value;
+ value--;
+ return last;
+ }
+
+ /**
+ * Decrements this instance's value by 1; this method returns the value associated with the instance
+ * immediately after the decrement operation. This method is not thread safe.
+ *
+ * @return the value associated with the instance after it is decremented
+ */
+ public byte decrementAndGet() {
+ value--;
+ return value;
+ }
+
//-----------------------------------------------------------------------
/**
* Adds a value to the value of this instance.
@@ -171,6 +217,58 @@ public class MutableByte extends Number implements Comparable<MutableByte>, Muta
this.value -= operand.byteValue();
}
+ /**
+ * Increments this instance's value by {@code operand}; this method returns the value associated with the instance
+ * immediately after the addition operation. This method is not thread safe.
+ *
+ * @param operand the quantity to add, not null
+ * @return the value associated with this instance after adding the operand
+ */
+ public byte addAndGet(final byte operand) {
+ this.value += operand;
+ return value;
+ }
+
+ /**
+ * Increments this instance's value by {@code operand}; this method returns the value associated with the instance
+ * immediately after the addition operation. This method is not thread safe.
+ *
+ * @param operand the quantity to add, not null
+ * @throws NullPointerException if {@code operand} is null
+ * @return the value associated with this instance after adding the operand
+ */
+ public byte addAndGet(final Number operand) {
+ this.value += operand.byteValue();
+ return value;
+ }
+
+ /**
+ * Increments this instance's value by {@code operand}; this method returns the value associated with the instance
+ * immediately prior to the addition operation. This method is not thread safe.
+ *
+ * @param operand the quantity to add, not null
+ * @return the value associated with this instance immediately before the operand was added
+ */
+ public byte getAndAdd(final byte operand) {
+ byte last = value;
+ this.value += operand;
+ return last;
+ }
+
+ /**
+ * Increments this instance's value by {@code operand}; this method returns the value associated with the instance
+ * immediately prior to the addition operation. This method is not thread safe.
+ *
+ * @param operand the quantity to add, not null
+ * @throws NullPointerException if {@code operand} is null
+ * @return the value associated with this instance immediately before the operand was added
+ */
+ public byte getAndAdd(final Number operand) {
+ byte last = value;
+ this.value += operand.byteValue();
+ return last;
+ }
+
//-----------------------------------------------------------------------
// shortValue relies on Number implementation
/**
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/e4742636/src/main/java/org/apache/commons/lang3/mutable/MutableDouble.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/mutable/MutableDouble.java b/src/main/java/org/apache/commons/lang3/mutable/MutableDouble.java
index 855b04c..633b8fb 100644
--- a/src/main/java/org/apache/commons/lang3/mutable/MutableDouble.java
+++ b/src/main/java/org/apache/commons/lang3/mutable/MutableDouble.java
@@ -137,6 +137,29 @@ public class MutableDouble extends Number implements Comparable<MutableDouble>,
}
/**
+ * Increments this instance's value by 1; this method returns the value associated with the instance
+ * immediately prior to the increment operation. This method is not thread safe.
+ *
+ * @return the value associated with the instance before it was incremented
+ */
+ public double getAndIncrement() {
+ double last = value;
+ value++;
+ return last;
+ }
+
+ /**
+ * Increments this instance's value by 1; this method returns the value associated with the instance
+ * immediately after the increment operation. This method is not thread safe.
+ *
+ * @return the value associated with the instance after it is incremented
+ */
+ public double incrementAndGet() {
+ value++;
+ return value;
+ }
+
+ /**
* Decrements the value.
*
* @since Commons Lang 2.2
@@ -145,6 +168,29 @@ public class MutableDouble extends Number implements Comparable<MutableDouble>,
value--;
}
+ /**
+ * Decrements this instance's value by 1; this method returns the value associated with the instance
+ * immediately prior to the decrement operation. This method is not thread safe.
+ *
+ * @return the value associated with the instance before it was decremented
+ */
+ public double getAndDecrement() {
+ double last = value;
+ value--;
+ return last;
+ }
+
+ /**
+ * Decrements this instance's value by 1; this method returns the value associated with the instance
+ * immediately after the decrement operation. This method is not thread safe.
+ *
+ * @return the value associated with the instance after it is decremented
+ */
+ public double decrementAndGet() {
+ value--;
+ return value;
+ }
+
//-----------------------------------------------------------------------
/**
* Adds a value to the value of this instance.
@@ -188,6 +234,58 @@ public class MutableDouble extends Number implements Comparable<MutableDouble>,
this.value -= operand.doubleValue();
}
+ /**
+ * Increments this instance's value by {@code operand}; this method returns the value associated with the instance
+ * immediately after the addition operation. This method is not thread safe.
+ *
+ * @param operand the quantity to add, not null
+ * @return the value associated with this instance after adding the operand
+ */
+ public double addAndGet(final double operand) {
+ this.value += operand;
+ return value;
+ }
+
+ /**
+ * Increments this instance's value by {@code operand}; this method returns the value associated with the instance
+ * immediately after the addition operation. This method is not thread safe.
+ *
+ * @param operand the quantity to add, not null
+ * @throws NullPointerException if {@code operand} is null
+ * @return the value associated with this instance after adding the operand
+ */
+ public double addAndGet(final Number operand) {
+ this.value += operand.doubleValue();
+ return value;
+ }
+
+ /**
+ * Increments this instance's value by {@code operand}; this method returns the value associated with the instance
+ * immediately prior to the addition operation. This method is not thread safe.
+ *
+ * @param operand the quantity to add, not null
+ * @return the value associated with this instance immediately before the operand was added
+ */
+ public double getAndAdd(final double operand) {
+ double last = value;
+ this.value += operand;
+ return last;
+ }
+
+ /**
+ * Increments this instance's value by {@code operand}; this method returns the value associated with the instance
+ * immediately prior to the addition operation. This method is not thread safe.
+ *
+ * @param operand the quantity to add, not null
+ * @throws NullPointerException if {@code operand} is null
+ * @return the value associated with this instance immediately before the operand was added
+ */
+ public double getAndAdd(final Number operand) {
+ double last = value;
+ this.value += operand.doubleValue();
+ return last;
+ }
+
//-----------------------------------------------------------------------
// shortValue and byteValue rely on Number implementation
/**
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/e4742636/src/main/java/org/apache/commons/lang3/mutable/MutableFloat.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/mutable/MutableFloat.java b/src/main/java/org/apache/commons/lang3/mutable/MutableFloat.java
index 7f798f7..9fc2955 100644
--- a/src/main/java/org/apache/commons/lang3/mutable/MutableFloat.java
+++ b/src/main/java/org/apache/commons/lang3/mutable/MutableFloat.java
@@ -137,6 +137,29 @@ public class MutableFloat extends Number implements Comparable<MutableFloat>, Mu
}
/**
+ * Increments this instance's value by 1; this method returns the value associated with the instance
+ * immediately prior to the increment operation. This method is not thread safe.
+ *
+ * @return the value associated with the instance before it was incremented
+ */
+ public float getAndIncrement() {
+ float last = value;
+ value++;
+ return last;
+ }
+
+ /**
+ * Increments this instance's value by 1; this method returns the value associated with the instance
+ * immediately after the increment operation. This method is not thread safe.
+ *
+ * @return the value associated with the instance after it is incremented
+ */
+ public float incrementAndGet() {
+ value++;
+ return value;
+ }
+
+ /**
* Decrements the value.
*
* @since Commons Lang 2.2
@@ -145,6 +168,29 @@ public class MutableFloat extends Number implements Comparable<MutableFloat>, Mu
value--;
}
+ /**
+ * Decrements this instance's value by 1; this method returns the value associated with the instance
+ * immediately prior to the decrement operation. This method is not thread safe.
+ *
+ * @return the value associated with the instance before it was decremented
+ */
+ public float getAndDecrement() {
+ float last = value;
+ value--;
+ return last;
+ }
+
+ /**
+ * Decrements this instance's value by 1; this method returns the value associated with the instance
+ * immediately after the decrement operation. This method is not thread safe.
+ *
+ * @return the value associated with the instance after it is decremented
+ */
+ public float decrementAndGet() {
+ value--;
+ return value;
+ }
+
//-----------------------------------------------------------------------
/**
* Adds a value to the value of this instance.
@@ -188,6 +234,58 @@ public class MutableFloat extends Number implements Comparable<MutableFloat>, Mu
this.value -= operand.floatValue();
}
+ /**
+ * Increments this instance's value by {@code operand}; this method returns the value associated with the instance
+ * immediately after the addition operation. This method is not thread safe.
+ *
+ * @param operand the quantity to add, not null
+ * @return the value associated with this instance after adding the operand
+ */
+ public float addAndGet(final float operand) {
+ this.value += operand;
+ return value;
+ }
+
+ /**
+ * Increments this instance's value by {@code operand}; this method returns the value associated with the instance
+ * immediately after the addition operation. This method is not thread safe.
+ *
+ * @param operand the quantity to add, not null
+ * @throws NullPointerException if {@code operand} is null
+ * @return the value associated with this instance after adding the operand
+ */
+ public float addAndGet(final Number operand) {
+ this.value += operand.floatValue();
+ return value;
+ }
+
+ /**
+ * Increments this instance's value by {@code operand}; this method returns the value associated with the instance
+ * immediately prior to the addition operation. This method is not thread safe.
+ *
+ * @param operand the quantity to add, not null
+ * @return the value associated with this instance immediately before the operand was added
+ */
+ public float getAndAdd(final float operand) {
+ float last = value;
+ this.value += operand;
+ return last;
+ }
+
+ /**
+ * Increments this instance's value by {@code operand}; this method returns the value associated with the instance
+ * immediately prior to the addition operation. This method is not thread safe.
+ *
+ * @param operand the quantity to add, not null
+ * @throws NullPointerException if {@code operand} is null
+ * @return the value associated with this instance immediately before the operand was added
+ */
+ public float getAndAdd(final Number operand) {
+ float last = value;
+ this.value += operand.floatValue();
+ return last;
+ }
+
//-----------------------------------------------------------------------
// shortValue and byteValue rely on Number implementation
/**
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/e4742636/src/main/java/org/apache/commons/lang3/mutable/MutableInt.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/mutable/MutableInt.java b/src/main/java/org/apache/commons/lang3/mutable/MutableInt.java
index 1b86ade..dd490cd 100644
--- a/src/main/java/org/apache/commons/lang3/mutable/MutableInt.java
+++ b/src/main/java/org/apache/commons/lang3/mutable/MutableInt.java
@@ -120,6 +120,29 @@ public class MutableInt extends Number implements Comparable<MutableInt>, Mutabl
}
/**
+ * Increments this instance's value by 1; this method returns the value associated with the instance
+ * immediately prior to the increment operation. This method is not thread safe.
+ *
+ * @return the value associated with the instance before it was incremented
+ */
+ public int getAndIncrement() {
+ int last = value;
+ value++;
+ return last;
+ }
+
+ /**
+ * Increments this instance's value by 1; this method returns the value associated with the instance
+ * immediately after the increment operation. This method is not thread safe.
+ *
+ * @return the value associated with the instance after it is incremented
+ */
+ public int incrementAndGet() {
+ value++;
+ return value;
+ }
+
+ /**
* Decrements the value.
*
* @since Commons Lang 2.2
@@ -128,6 +151,29 @@ public class MutableInt extends Number implements Comparable<MutableInt>, Mutabl
value--;
}
+ /**
+ * Decrements this instance's value by 1; this method returns the value associated with the instance
+ * immediately prior to the decrement operation. This method is not thread safe.
+ *
+ * @return the value associated with the instance before it was decremented
+ */
+ public int getAndDecrement() {
+ int last = value;
+ value--;
+ return last;
+ }
+
+ /**
+ * Decrements this instance's value by 1; this method returns the value associated with the instance
+ * immediately after the decrement operation. This method is not thread safe.
+ *
+ * @return the value associated with the instance after it is decremented
+ */
+ public int decrementAndGet() {
+ value--;
+ return value;
+ }
+
//-----------------------------------------------------------------------
/**
* Adds a value to the value of this instance.
@@ -171,6 +217,58 @@ public class MutableInt extends Number implements Comparable<MutableInt>, Mutabl
this.value -= operand.intValue();
}
+ /**
+ * Increments this instance's value by {@code operand}; this method returns the value associated with the instance
+ * immediately after the addition operation. This method is not thread safe.
+ *
+ * @param operand the quantity to add, not null
+ * @return the value associated with this instance after adding the operand
+ */
+ public int addAndGet(final int operand) {
+ this.value += operand;
+ return value;
+ }
+
+ /**
+ * Increments this instance's value by {@code operand}; this method returns the value associated with the instance
+ * immediately after the addition operation. This method is not thread safe.
+ *
+ * @param operand the quantity to add, not null
+ * @throws NullPointerException if {@code operand} is null
+ * @return the value associated with this instance after adding the operand
+ */
+ public int addAndGet(final Number operand) {
+ this.value += operand.intValue();
+ return value;
+ }
+
+ /**
+ * Increments this instance's value by {@code operand}; this method returns the value associated with the instance
+ * immediately prior to the addition operation. This method is not thread safe.
+ *
+ * @param operand the quantity to add, not null
+ * @return the value associated with this instance immediately before the operand was added
+ */
+ public int getAndAdd(final int operand) {
+ int last = value;
+ this.value += operand;
+ return last;
+ }
+
+ /**
+ * Increments this instance's value by {@code operand}; this method returns the value associated with the instance
+ * immediately prior to the addition operation. This method is not thread safe.
+ *
+ * @param operand the quantity to add, not null
+ * @throws NullPointerException if {@code operand} is null
+ * @return the value associated with this instance immediately before the operand was added
+ */
+ public int getAndAdd(final Number operand) {
+ int last = value;
+ this.value += operand.intValue();
+ return last;
+ }
+
//-----------------------------------------------------------------------
// shortValue and byteValue rely on Number implementation
/**
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/e4742636/src/main/java/org/apache/commons/lang3/mutable/MutableLong.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/mutable/MutableLong.java b/src/main/java/org/apache/commons/lang3/mutable/MutableLong.java
index d9391c4..01bbef6 100644
--- a/src/main/java/org/apache/commons/lang3/mutable/MutableLong.java
+++ b/src/main/java/org/apache/commons/lang3/mutable/MutableLong.java
@@ -120,6 +120,29 @@ public class MutableLong extends Number implements Comparable<MutableLong>, Muta
}
/**
+ * Increments this instance's value by 1; this method returns the value associated with the instance
+ * immediately prior to the increment operation. This method is not thread safe.
+ *
+ * @return the value associated with the instance before it was incremented
+ */
+ public long getAndIncrement() {
+ long last = value;
+ value++;
+ return last;
+ }
+
+ /**
+ * Increments this instance's value by 1; this method returns the value associated with the instance
+ * immediately after the increment operation. This method is not thread safe.
+ *
+ * @return the value associated with the instance after it is incremented
+ */
+ public long incrementAndGet() {
+ value++;
+ return value;
+ }
+
+ /**
* Decrements the value.
*
* @since Commons Lang 2.2
@@ -128,6 +151,29 @@ public class MutableLong extends Number implements Comparable<MutableLong>, Muta
value--;
}
+ /**
+ * Decrements this instance's value by 1; this method returns the value associated with the instance
+ * immediately prior to the decrement operation. This method is not thread safe.
+ *
+ * @return the value associated with the instance before it was decremented
+ */
+ public long getAndDecrement() {
+ long last = value;
+ value--;
+ return last;
+ }
+
+ /**
+ * Decrements this instance's value by 1; this method returns the value associated with the instance
+ * immediately after the decrement operation. This method is not thread safe.
+ *
+ * @return the value associated with the instance after it is decremented
+ */
+ public long decrementAndGet() {
+ value--;
+ return value;
+ }
+
//-----------------------------------------------------------------------
/**
* Adds a value to the value of this instance.
@@ -171,6 +217,58 @@ public class MutableLong extends Number implements Comparable<MutableLong>, Muta
this.value -= operand.longValue();
}
+ /**
+ * Increments this instance's value by {@code operand}; this method returns the value associated with the instance
+ * immediately after the addition operation. This method is not thread safe.
+ *
+ * @param operand the quantity to add, not null
+ * @return the value associated with this instance after adding the operand
+ */
+ public long addAndGet(final long operand) {
+ this.value += operand;
+ return value;
+ }
+
+ /**
+ * Increments this instance's value by {@code operand}; this method returns the value associated with the instance
+ * immediately after the addition operation. This method is not thread safe.
+ *
+ * @param operand the quantity to add, not null
+ * @throws NullPointerException if {@code operand} is null
+ * @return the value associated with this instance after adding the operand
+ */
+ public long addAndGet(final Number operand) {
+ this.value += operand.longValue();
+ return value;
+ }
+
+ /**
+ * Increments this instance's value by {@code operand}; this method returns the value associated with the instance
+ * immediately prior to the addition operation. This method is not thread safe.
+ *
+ * @param operand the quantity to add, not null
+ * @return the value associated with this instance immediately before the operand was added
+ */
+ public long getAndAdd(final long operand) {
+ long last = value;
+ this.value += operand;
+ return last;
+ }
+
+ /**
+ * Increments this instance's value by {@code operand}; this method returns the value associated with the instance
+ * immediately prior to the addition operation. This method is not thread safe.
+ *
+ * @param operand the quantity to add, not null
+ * @throws NullPointerException if {@code operand} is null
+ * @return the value associated with this instance immediately before the operand was added
+ */
+ public long getAndAdd(final Number operand) {
+ long last = value;
+ this.value += operand.longValue();
+ return last;
+ }
+
//-----------------------------------------------------------------------
// shortValue and byteValue rely on Number implementation
/**
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/e4742636/src/main/java/org/apache/commons/lang3/mutable/MutableShort.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/mutable/MutableShort.java b/src/main/java/org/apache/commons/lang3/mutable/MutableShort.java
index 5313245..2125f44 100644
--- a/src/main/java/org/apache/commons/lang3/mutable/MutableShort.java
+++ b/src/main/java/org/apache/commons/lang3/mutable/MutableShort.java
@@ -120,6 +120,29 @@ public class MutableShort extends Number implements Comparable<MutableShort>, Mu
}
/**
+ * Increments this instance's value by 1; this method returns the value associated with the instance
+ * immediately prior to the increment operation. This method is not thread safe.
+ *
+ * @return the value associated with the instance before it was incremented
+ */
+ public short getAndIncrement() {
+ short last = value;
+ value++;
+ return last;
+ }
+
+ /**
+ * Increments this instance's value by 1; this method returns the value associated with the instance
+ * immediately after the increment operation. This method is not thread safe.
+ *
+ * @return the value associated with the instance after it is incremented
+ */
+ public short incrementAndGet() {
+ value++;
+ return value;
+ }
+
+ /**
* Decrements the value.
*
* @since Commons Lang 2.2
@@ -128,6 +151,29 @@ public class MutableShort extends Number implements Comparable<MutableShort>, Mu
value--;
}
+ /**
+ * Decrements this instance's value by 1; this method returns the value associated with the instance
+ * immediately prior to the decrement operation. This method is not thread safe.
+ *
+ * @return the value associated with the instance before it was decremented
+ */
+ public short getAndDecrement() {
+ short last = value;
+ value--;
+ return last;
+ }
+
+ /**
+ * Decrements this instance's value by 1; this method returns the value associated with the instance
+ * immediately after the decrement operation. This method is not thread safe.
+ *
+ * @return the value associated with the instance after it is decremented
+ */
+ public short decrementAndGet() {
+ value--;
+ return value;
+ }
+
//-----------------------------------------------------------------------
/**
* Adds a value to the value of this instance.
@@ -171,6 +217,58 @@ public class MutableShort extends Number implements Comparable<MutableShort>, Mu
this.value -= operand.shortValue();
}
+ /**
+ * Increments this instance's value by {@code operand}; this method returns the value associated with the instance
+ * immediately after the addition operation. This method is not thread safe.
+ *
+ * @param operand the quantity to add, not null
+ * @return the value associated with this instance after adding the operand
+ */
+ public short addAndGet(final short operand) {
+ this.value += operand;
+ return value;
+ }
+
+ /**
+ * Increments this instance's value by {@code operand}; this method returns the value associated with the instance
+ * immediately after the addition operation. This method is not thread safe.
+ *
+ * @param operand the quantity to add, not null
+ * @throws NullPointerException if {@code operand} is null
+ * @return the value associated with this instance after adding the operand
+ */
+ public short addAndGet(final Number operand) {
+ this.value += operand.shortValue();
+ return value;
+ }
+
+ /**
+ * Increments this instance's value by {@code operand}; this method returns the value associated with the instance
+ * immediately prior to the addition operation. This method is not thread safe.
+ *
+ * @param operand the quantity to add, not null
+ * @return the value associated with this instance immediately before the operand was added
+ */
+ public short getAndAdd(final short operand) {
+ short last = value;
+ this.value += operand;
+ return last;
+ }
+
+ /**
+ * Increments this instance's value by {@code operand}; this method returns the value associated with the instance
+ * immediately prior to the addition operation. This method is not thread safe.
+ *
+ * @param operand the quantity to add, not null
+ * @throws NullPointerException if {@code operand} is null
+ * @return the value associated with this instance immediately before the operand was added
+ */
+ public short getAndAdd(final Number operand) {
+ short last = value;
+ this.value += operand.shortValue();
+ return last;
+ }
+
//-----------------------------------------------------------------------
// byteValue relies on Number implementation
/**
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/e4742636/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java
index 37bddfa..4903730 100644
--- a/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java
+++ b/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java
@@ -143,6 +143,26 @@ public class MutableByteTest {
}
@Test
+ public void testIncrementAndGet() {
+ final MutableByte mutNum = new MutableByte((byte) 1);
+ byte result = mutNum.incrementAndGet();
+
+ assertEquals(2, result);
+ assertEquals(2, mutNum.intValue());
+ assertEquals(2L, mutNum.longValue());
+ }
+
+ @Test
+ public void testGetAndIncrement() {
+ final MutableByte mutNum = new MutableByte((byte) 1);
+ byte result = mutNum.getAndIncrement();
+
+ assertEquals(1, result);
+ assertEquals(2, mutNum.intValue());
+ assertEquals(2L, mutNum.longValue());
+ }
+
+ @Test
public void testDecrement() {
final MutableByte mutNum = new MutableByte((byte) 1);
mutNum.decrement();
@@ -152,6 +172,26 @@ public class MutableByteTest {
}
@Test
+ public void testDecrementAndGet() {
+ final MutableByte mutNum = new MutableByte((byte) 1);
+ byte result = mutNum.decrementAndGet();
+
+ assertEquals(0, result);
+ assertEquals(0, mutNum.intValue());
+ assertEquals(0L, mutNum.longValue());
+ }
+
+ @Test
+ public void testGetAndDecrement() {
+ final MutableByte mutNum = new MutableByte((byte) 1);
+ byte result = mutNum.getAndDecrement();
+
+ assertEquals(1, result);
+ assertEquals(0, mutNum.intValue());
+ assertEquals(0L, mutNum.longValue());
+ }
+
+ @Test
public void testAddValuePrimitive() {
final MutableByte mutNum = new MutableByte((byte) 1);
mutNum.add((byte)1);
@@ -168,6 +208,42 @@ public class MutableByteTest {
}
@Test
+ public void testGetAndAddValuePrimitive() {
+ final MutableByte mutableByte = new MutableByte((byte)0);
+ byte result = mutableByte.getAndAdd((byte) 1);
+
+ assertEquals((byte) 0, result);
+ assertEquals((byte) 1, mutableByte.byteValue());
+ }
+
+ @Test
+ public void testGetAndAddValueObject() {
+ final MutableByte mutableByte = new MutableByte((byte)0);
+ byte result = mutableByte.getAndAdd(Byte.valueOf((byte) 1));
+
+ assertEquals((byte) 0, result);
+ assertEquals((byte) 1, mutableByte.byteValue());
+ }
+
+ @Test
+ public void testAddAndGetValuePrimitive() {
+ final MutableByte mutableByte = new MutableByte((byte)0);
+ byte result = mutableByte.addAndGet((byte) 1);
+
+ assertEquals((byte) 1, result);
+ assertEquals((byte) 1, mutableByte.byteValue());
+ }
+
+ @Test
+ public void testAddAndGetValueObject() {
+ final MutableByte mutableByte = new MutableByte((byte)0);
+ byte result = mutableByte.addAndGet(Byte.valueOf((byte) 1));
+
+ assertEquals((byte) 1, result);
+ assertEquals((byte) 1, mutableByte.byteValue());
+ }
+
+ @Test
public void testSubtractValuePrimitive() {
final MutableByte mutNum = new MutableByte((byte) 1);
mutNum.subtract((byte) 1);
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/e4742636/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java
index af071fc..95dab59 100644
--- a/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java
+++ b/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java
@@ -155,6 +155,26 @@ public class MutableDoubleTest {
}
@Test
+ public void testIncrementAndGet() {
+ final MutableDouble mutNum = new MutableDouble(1d);
+ double result = mutNum.incrementAndGet();
+
+ assertEquals(2d, result, 0.01d);
+ assertEquals(2, mutNum.intValue());
+ assertEquals(2L, mutNum.longValue());
+ }
+
+ @Test
+ public void testGetAndIncrement() {
+ final MutableDouble mutNum = new MutableDouble(1d);
+ double result = mutNum.getAndIncrement();
+
+ assertEquals(1d, result, 0.01d);
+ assertEquals(2, mutNum.intValue());
+ assertEquals(2L, mutNum.longValue());
+ }
+
+ @Test
public void testDecrement() {
final MutableDouble mutNum = new MutableDouble(1);
mutNum.decrement();
@@ -164,6 +184,26 @@ public class MutableDoubleTest {
}
@Test
+ public void testDecrementAndGet() {
+ final MutableDouble mutNum = new MutableDouble(1d);
+ double result = mutNum.decrementAndGet();
+
+ assertEquals(0d, result, 0.01d);
+ assertEquals(0, mutNum.intValue());
+ assertEquals(0L, mutNum.longValue());
+ }
+
+ @Test
+ public void testGetAndDecrement() {
+ final MutableDouble mutNum = new MutableDouble(1d);
+ double result = mutNum.getAndDecrement();
+
+ assertEquals(1d, result, 0.01d);
+ assertEquals(0, mutNum.intValue());
+ assertEquals(0L, mutNum.longValue());
+ }
+
+ @Test
public void testAddValuePrimitive() {
final MutableDouble mutNum = new MutableDouble(1);
mutNum.add(1.1d);
@@ -180,6 +220,42 @@ public class MutableDoubleTest {
}
@Test
+ public void testGetAndAddValuePrimitive() {
+ final MutableDouble mutableDouble = new MutableDouble(0.5d);
+ double result = mutableDouble.getAndAdd(1d);
+
+ assertEquals(0.5d, result, 0.01d);
+ assertEquals(1.5d, mutableDouble.doubleValue(), 0.01d);
+ }
+
+ @Test
+ public void testGetAndAddValueObject() {
+ final MutableDouble mutableDouble = new MutableDouble(0.5d);
+ double result = mutableDouble.getAndAdd(Double.valueOf(2d));
+
+ assertEquals(0.5d, result, 0.01d);
+ assertEquals(2.5d, mutableDouble.doubleValue(), 0.01d);
+ }
+
+ @Test
+ public void testAddAndGetValuePrimitive() {
+ final MutableDouble mutableDouble = new MutableDouble(10.5d);
+ double result = mutableDouble.addAndGet(-0.5d);
+
+ assertEquals(10d, result, 0.01d);
+ assertEquals(10d, mutableDouble.doubleValue(), 0.01d);
+ }
+
+ @Test
+ public void testAddAndGetValueObject() {
+ final MutableDouble mutableDouble = new MutableDouble(7.5d);
+ double result = mutableDouble.addAndGet(Double.valueOf(-2.5d));
+
+ assertEquals(5d, result, 0.01d);
+ assertEquals(5d, mutableDouble.doubleValue(), 0.01d);
+ }
+
+ @Test
public void testSubtractValuePrimitive() {
final MutableDouble mutNum = new MutableDouble(1);
mutNum.subtract(0.9d);
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/e4742636/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java
index 2f67c13..f507cb4 100644
--- a/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java
+++ b/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java
@@ -155,6 +155,26 @@ public class MutableFloatTest {
}
@Test
+ public void testIncrementAndGet() {
+ final MutableFloat mutNum = new MutableFloat(1f);
+ float result = mutNum.incrementAndGet();
+
+ assertEquals(2f, result, 0.01f);
+ assertEquals(2, mutNum.intValue());
+ assertEquals(2L, mutNum.longValue());
+ }
+
+ @Test
+ public void testGetAndIncrement() {
+ final MutableFloat mutNum = new MutableFloat(1f);
+ float result = mutNum.getAndIncrement();
+
+ assertEquals(1f, result, 0.01f);
+ assertEquals(2, mutNum.intValue());
+ assertEquals(2L, mutNum.longValue());
+ }
+
+ @Test
public void testDecrement() {
final MutableFloat mutNum = new MutableFloat(1);
mutNum.decrement();
@@ -164,6 +184,26 @@ public class MutableFloatTest {
}
@Test
+ public void testDecrementAndGet() {
+ final MutableFloat mutNum = new MutableFloat(1f);
+ float result = mutNum.decrementAndGet();
+
+ assertEquals(0f, result, 0.01f);
+ assertEquals(0, mutNum.intValue());
+ assertEquals(0L, mutNum.longValue());
+ }
+
+ @Test
+ public void testGetAndDecrement() {
+ final MutableFloat mutNum = new MutableFloat(1f);
+ float result = mutNum.getAndDecrement();
+
+ assertEquals(1f, result, 0.01f);
+ assertEquals(0, mutNum.intValue());
+ assertEquals(0L, mutNum.longValue());
+ }
+
+ @Test
public void testAddValuePrimitive() {
final MutableFloat mutNum = new MutableFloat(1);
mutNum.add(1.1f);
@@ -180,6 +220,42 @@ public class MutableFloatTest {
}
@Test
+ public void testGetAndAddValuePrimitive() {
+ final MutableFloat mutableFloat = new MutableFloat(1.25f);
+ float result = mutableFloat.getAndAdd(0.75f);
+
+ assertEquals(1.25f, result, 0.01f);
+ assertEquals(2f, mutableFloat.floatValue(), 0.01f);
+ }
+
+ @Test
+ public void testGetAndAddValueObject() {
+ final MutableFloat mutableFloat = new MutableFloat(7.75f);
+ float result = mutableFloat.getAndAdd(Float.valueOf(2.25f));
+
+ assertEquals(7.75f, result, 0.01f);
+ assertEquals(10f, mutableFloat.floatValue(), 0.01f);
+ }
+
+ @Test
+ public void testAddAndGetValuePrimitive() {
+ final MutableFloat mutableFloat = new MutableFloat(0.5f);
+ float result = mutableFloat.addAndGet(1f);
+
+ assertEquals(1.5f, result, 0.01f);
+ assertEquals(1.5f, mutableFloat.floatValue(), 0.01f);
+ }
+
+ @Test
+ public void testAddAndGetValueObject() {
+ final MutableFloat mutableFloat = new MutableFloat(5f);
+ float result = mutableFloat.addAndGet(Float.valueOf(2.5f));
+
+ assertEquals(7.5f, result, 0.01f);
+ assertEquals(7.5f, mutableFloat.floatValue(), 0.01f);
+ }
+
+ @Test
public void testSubtractValuePrimitive() {
final MutableFloat mutNum = new MutableFloat(1);
mutNum.subtract(0.9f);
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/e4742636/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java
index e18fd5f..d21c7a3 100644
--- a/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java
+++ b/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java
@@ -149,6 +149,26 @@ public class MutableIntTest {
}
@Test
+ public void testIncrementAndGet() {
+ final MutableInt mutNum = new MutableInt((int) 1);
+ int result = mutNum.incrementAndGet();
+
+ assertEquals(2, result);
+ assertEquals(2, mutNum.intValue());
+ assertEquals(2L, mutNum.longValue());
+ }
+
+ @Test
+ public void testGetAndIncrement() {
+ final MutableInt mutNum = new MutableInt((int) 1);
+ int result = mutNum.getAndIncrement();
+
+ assertEquals(1, result);
+ assertEquals(2, mutNum.intValue());
+ assertEquals(2L, mutNum.longValue());
+ }
+
+ @Test
public void testDecrement() {
final MutableInt mutNum = new MutableInt(1);
mutNum.decrement();
@@ -158,6 +178,26 @@ public class MutableIntTest {
}
@Test
+ public void testDecrementAndGet() {
+ final MutableInt mutNum = new MutableInt((int) 1);
+ int result = mutNum.decrementAndGet();
+
+ assertEquals(0, result);
+ assertEquals(0, mutNum.intValue());
+ assertEquals(0L, mutNum.longValue());
+ }
+
+ @Test
+ public void testGetAndDecrement() {
+ final MutableInt mutNum = new MutableInt((int) 1);
+ int result = mutNum.getAndDecrement();
+
+ assertEquals(1, result);
+ assertEquals(0, mutNum.intValue());
+ assertEquals(0L, mutNum.longValue());
+ }
+
+ @Test
public void testAddValuePrimitive() {
final MutableInt mutNum = new MutableInt(1);
mutNum.add(1);
@@ -176,6 +216,42 @@ public class MutableIntTest {
}
@Test
+ public void testGetAndAddValuePrimitive() {
+ final MutableInt mutableInteger = new MutableInt((int)0);
+ int result = mutableInteger.getAndAdd((int) 1);
+
+ assertEquals((int) 0, result);
+ assertEquals((int) 1, mutableInteger.intValue());
+ }
+
+ @Test
+ public void testGetAndAddValueObject() {
+ final MutableInt mutableInteger = new MutableInt((int)0);
+ int result = mutableInteger.getAndAdd(Integer.valueOf((int) 1));
+
+ assertEquals((int) 0, result);
+ assertEquals((int) 1, mutableInteger.intValue());
+ }
+
+ @Test
+ public void testAddAndGetValuePrimitive() {
+ final MutableInt mutableInteger = new MutableInt((int)0);
+ int result = mutableInteger.addAndGet((int) 1);
+
+ assertEquals((int) 1, result);
+ assertEquals((int) 1, mutableInteger.intValue());
+ }
+
+ @Test
+ public void testAddAndGetValueObject() {
+ final MutableInt mutableInteger = new MutableInt((int)0);
+ int result = mutableInteger.addAndGet(Integer.valueOf((int) 1));
+
+ assertEquals((int) 1, result);
+ assertEquals((int) 1, mutableInteger.intValue());
+ }
+
+ @Test
public void testSubtractValuePrimitive() {
final MutableInt mutNum = new MutableInt(1);
mutNum.subtract(1);
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/e4742636/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java
index 936c4ef..c2e66a2 100644
--- a/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java
+++ b/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java
@@ -143,6 +143,26 @@ public class MutableLongTest {
}
@Test
+ public void testIncrementAndGet() {
+ final MutableLong mutNum = new MutableLong((long) 1);
+ long result = mutNum.incrementAndGet();
+
+ assertEquals(2, result);
+ assertEquals(2, mutNum.intValue());
+ assertEquals(2L, mutNum.longValue());
+ }
+
+ @Test
+ public void testGetAndIncrement() {
+ final MutableLong mutNum = new MutableLong((long) 1);
+ long result = mutNum.getAndIncrement();
+
+ assertEquals(1, result);
+ assertEquals(2, mutNum.intValue());
+ assertEquals(2L, mutNum.longValue());
+ }
+
+ @Test
public void testDecrement() {
final MutableLong mutNum = new MutableLong(1);
mutNum.decrement();
@@ -152,6 +172,26 @@ public class MutableLongTest {
}
@Test
+ public void testDecrementAndGet() {
+ final MutableLong mutNum = new MutableLong((long) 1);
+ long result = mutNum.decrementAndGet();
+
+ assertEquals(0, result);
+ assertEquals(0, mutNum.intValue());
+ assertEquals(0L, mutNum.longValue());
+ }
+
+ @Test
+ public void testGetAndDecrement() {
+ final MutableLong mutNum = new MutableLong((long) 1);
+ long result = mutNum.getAndDecrement();
+
+ assertEquals(1, result);
+ assertEquals(0, mutNum.intValue());
+ assertEquals(0L, mutNum.longValue());
+ }
+
+ @Test
public void testAddValuePrimitive() {
final MutableLong mutNum = new MutableLong(1);
mutNum.add(1);
@@ -170,6 +210,42 @@ public class MutableLongTest {
}
@Test
+ public void testGetAndAddValuePrimitive() {
+ final MutableLong mutableLong = new MutableLong((long)0);
+ long result = mutableLong.getAndAdd((long) 1);
+
+ assertEquals((long) 0, result);
+ assertEquals((long) 1, mutableLong.longValue());
+ }
+
+ @Test
+ public void testGetAndAddValueObject() {
+ final MutableLong mutableLong = new MutableLong((long)0);
+ long result = mutableLong.getAndAdd(Long.valueOf((long) 1));
+
+ assertEquals((long) 0, result);
+ assertEquals((long) 1, mutableLong.longValue());
+ }
+
+ @Test
+ public void testAddAndGetValuePrimitive() {
+ final MutableLong mutableLong = new MutableLong((long)0);
+ long result = mutableLong.addAndGet((long) 1);
+
+ assertEquals((long) 1, result);
+ assertEquals((long) 1, mutableLong.longValue());
+ }
+
+ @Test
+ public void testAddAndGetValueObject() {
+ final MutableLong mutableLong = new MutableLong((long)0);
+ long result = mutableLong.addAndGet(Long.valueOf((long) 1));
+
+ assertEquals((long) 1, result);
+ assertEquals((long) 1, mutableLong.longValue());
+ }
+
+ @Test
public void testSubtractValuePrimitive() {
final MutableLong mutNum = new MutableLong(1);
mutNum.subtract(1);
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/e4742636/src/test/java/org/apache/commons/lang3/mutable/MutableShortTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableShortTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableShortTest.java
index a177185..5cd597d 100644
--- a/src/test/java/org/apache/commons/lang3/mutable/MutableShortTest.java
+++ b/src/test/java/org/apache/commons/lang3/mutable/MutableShortTest.java
@@ -138,6 +138,26 @@ public class MutableShortTest {
}
@Test
+ public void testIncrementAndGet() {
+ final MutableShort mutNum = new MutableShort((short) 1);
+ short result = mutNum.incrementAndGet();
+
+ assertEquals(2, result);
+ assertEquals(2, mutNum.intValue());
+ assertEquals(2L, mutNum.longValue());
+ }
+
+ @Test
+ public void testGetAndIncrement() {
+ final MutableShort mutNum = new MutableShort((short) 1);
+ short result = mutNum.getAndIncrement();
+
+ assertEquals(1, result);
+ assertEquals(2, mutNum.intValue());
+ assertEquals(2L, mutNum.longValue());
+ }
+
+ @Test
public void testDecrement() {
final MutableShort mutNum = new MutableShort((short) 1);
mutNum.decrement();
@@ -147,6 +167,26 @@ public class MutableShortTest {
}
@Test
+ public void testDecrementAndGet() {
+ final MutableShort mutNum = new MutableShort((short) 1);
+ short result = mutNum.decrementAndGet();
+
+ assertEquals(0, result);
+ assertEquals(0, mutNum.intValue());
+ assertEquals(0L, mutNum.longValue());
+ }
+
+ @Test
+ public void testGetAndDecrement() {
+ final MutableShort mutNum = new MutableShort((short) 1);
+ short result = mutNum.getAndDecrement();
+
+ assertEquals(1, result);
+ assertEquals(0, mutNum.intValue());
+ assertEquals(0L, mutNum.longValue());
+ }
+
+ @Test
public void testAddValuePrimitive() {
final MutableShort mutNum = new MutableShort((short) 1);
mutNum.add((short) 1);
@@ -163,6 +203,42 @@ public class MutableShortTest {
}
@Test
+ public void testGetAndAddValuePrimitive() {
+ final MutableShort mutableShort = new MutableShort((short)0);
+ short result = mutableShort.getAndAdd((short) 1);
+
+ assertEquals((short) 0, result);
+ assertEquals((short) 1, mutableShort.shortValue());
+ }
+
+ @Test
+ public void testGetAndAddValueObject() {
+ final MutableShort mutableShort = new MutableShort((short)0);
+ short result = mutableShort.getAndAdd(Short.valueOf((short) 1));
+
+ assertEquals((short) 0, result);
+ assertEquals((short) 1, mutableShort.shortValue());
+ }
+
+ @Test
+ public void testAddAndGetValuePrimitive() {
+ final MutableShort mutableShort = new MutableShort((short) 0);
+ short result = mutableShort.addAndGet((short) 1);
+
+ assertEquals((short) 1, result);
+ assertEquals((short) 1, mutableShort.shortValue());
+ }
+
+ @Test
+ public void testAddAndGetValueObject() {
+ final MutableShort mutableShort = new MutableShort((short) 0);
+ short result = mutableShort.addAndGet(Short.valueOf((short) 1));
+
+ assertEquals((short) 1, result);
+ assertEquals((short) 1, mutableShort.shortValue());
+ }
+
+ @Test
public void testSubtractValuePrimitive() {
final MutableShort mutNum = new MutableShort((short) 1);
mutNum.subtract((short) 1);