Skip to content

Commit 1d9093c

Browse files
committed
Deprecate NumberUtils.compare(int, int) in favor of Integer.compare(int,
int)
1 parent a1ea0e4 commit 1d9093c

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

src/changes/changes.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ The <action> type attribute can be add,update,fix,remove.
6262
<action type="fix" dev="ggregory" due-to="mayuming">Fix CalendarUtils.toLocalDate() Javadoc return type description #1440.</action>
6363
<action type="fix" dev="ggregory" due-to="mayuming">Fix the method name in Javadoc examples for CharUtils.isHex() #1444.</action>
6464
<action type="fix" dev="ggregory" due-to="Gary Gregory">Deprecate NumberUtils.compare(byte, byte) in favor of Byte.compare(byte, byte).</action>
65+
<action type="fix" dev="ggregory" due-to="Gary Gregory">Deprecate NumberUtils.compare(int, int) in favor of Integer.compare(int, int).</action>
6566
<!-- FIX Javadoc -->
6667
<action type="fix" dev="ggregory" due-to="Gary Gregory">[javadoc] General improvements.</action>
6768
<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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3714,7 +3714,7 @@ public static boolean isSorted(final int[] array) {
37143714
final int n = array.length;
37153715
for (int i = 1; i < n; i++) {
37163716
final int current = array[i];
3717-
if (NumberUtils.compare(previous, current) > 0) {
3717+
if (Integer.compare(previous, current) > 0) {
37183718
return false;
37193719
}
37203720
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
@@ -111,12 +111,11 @@ public static int compare(final byte x, final byte y) {
111111
* a value less than {@code 0} if {@code x < y}; and
112112
* a value greater than {@code 0} if {@code x > y}
113113
* @since 3.4
114+
* @deprecated Use {@link Integer#compare(int, int)}.
114115
*/
116+
@Deprecated
115117
public static int compare(final int x, final int y) {
116-
if (x == y) {
117-
return 0;
118-
}
119-
return x < y ? -1 : 1;
118+
return Integer.compare(x, y);
120119
}
121120

122121
/**

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
import java.util.concurrent.atomic.AtomicInteger;
2020

21-
import org.apache.commons.lang3.math.NumberUtils;
22-
2321
/**
2422
* A mutable {@code int} wrapper.
2523
* <p>
@@ -132,12 +130,12 @@ public int addAndGet(final Number operand) {
132130
/**
133131
* Compares this mutable to another in ascending order.
134132
*
135-
* @param other the other mutable to compare to, not null
136-
* @return negative if this is less, zero if equal, positive if greater
133+
* @param other the other mutable to compare to, not null.
134+
* @return negative if this is less, zero if equal, positive if greater.
137135
*/
138136
@Override
139137
public int compareTo(final MutableInt other) {
140-
return NumberUtils.compare(this.value, other.value);
138+
return Integer.compare(this.value, other.value);
141139
}
142140

143141
/**

0 commit comments

Comments
 (0)