Skip to content

Commit 9e8bf56

Browse files
committed
Deprecate NumberUtils.compare(short, short) in favor of
Short.compare(short, short)
1 parent 611887f commit 9e8bf56

4 files changed

Lines changed: 6 additions & 9 deletions

File tree

src/changes/changes.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ The <action> type attribute can be add,update,fix,remove.
6464
<action type="fix" dev="ggregory" due-to="Gary Gregory">Deprecate NumberUtils.compare(byte, byte) in favor of Byte.compare(byte, byte).</action>
6565
<action type="fix" dev="ggregory" due-to="Gary Gregory">Deprecate NumberUtils.compare(int, int) in favor of Integer.compare(int, int).</action>
6666
<action type="fix" dev="ggregory" due-to="Gary Gregory">Deprecate NumberUtils.compare(long, long) in favor of Long.compare(long, long).</action>
67+
<action type="fix" dev="ggregory" due-to="Gary Gregory">Deprecate NumberUtils.compare(short, short) in favor of Short.compare(short, short).</action>
6768
<!-- FIX Javadoc -->
6869
<action type="fix" dev="ggregory" due-to="Gary Gregory">[javadoc] General improvements.</action>
6970
<action type="fix" dev="ggregory" due-to="Gary Gregory">[javadoc] Fix thrown exception documentation for org.apache.commons.lang3.reflect.MethodUtils.getMethodObject(Class&lt;?&gt;, String, Class&lt;?&gt;...).</action>

src/main/java/org/apache/commons/lang3/ArrayUtils.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import org.apache.commons.lang3.builder.ToStringBuilder;
4040
import org.apache.commons.lang3.builder.ToStringStyle;
4141
import org.apache.commons.lang3.function.FailableFunction;
42-
import org.apache.commons.lang3.math.NumberUtils;
4342
import org.apache.commons.lang3.mutable.MutableInt;
4443
import org.apache.commons.lang3.stream.IntStreams;
4544
import org.apache.commons.lang3.stream.Streams;
@@ -3760,7 +3759,7 @@ public static boolean isSorted(final short[] array) {
37603759
final int n = array.length;
37613760
for (int i = 1; i < n; i++) {
37623761
final short current = array[i];
3763-
if (NumberUtils.compare(previous, current) > 0) {
3762+
if (Short.compare(previous, current) > 0) {
37643763
return false;
37653764
}
37663765
previous = current;

src/main/java/org/apache/commons/lang3/math/NumberUtils.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,11 @@ public static int compare(final long x, final long y) {
143143
* a value less than {@code 0} if {@code x < y}; and
144144
* a value greater than {@code 0} if {@code x > y}
145145
* @since 3.4
146+
* @deprecated Use {@link Short#compare(short, short)}.
146147
*/
148+
@Deprecated
147149
public static int compare(final short x, final short y) {
148-
if (x == y) {
149-
return 0;
150-
}
151-
return x < y ? -1 : 1;
150+
return Short.compare(x, y);
152151
}
153152

154153
/**

src/main/java/org/apache/commons/lang3/mutable/MutableShort.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
*/
1717
package org.apache.commons.lang3.mutable;
1818

19-
import org.apache.commons.lang3.math.NumberUtils;
20-
2119
/**
2220
* A mutable {@code short} wrapper.
2321
* <p>
@@ -131,7 +129,7 @@ public short addAndGet(final short operand) {
131129
*/
132130
@Override
133131
public int compareTo(final MutableShort other) {
134-
return NumberUtils.compare(this.value, other.value);
132+
return Short.compare(this.value, other.value);
135133
}
136134

137135
/**

0 commit comments

Comments
 (0)