use_Math_max_min (#547)
diff --git a/src/main/java/org/apache/commons/lang3/ArrayUtils.java b/src/main/java/org/apache/commons/lang3/ArrayUtils.java
index ee1b215..dd9b5ca 100644
--- a/src/main/java/org/apache/commons/lang3/ArrayUtils.java
+++ b/src/main/java/org/apache/commons/lang3/ArrayUtils.java
@@ -6523,7 +6523,7 @@
if (array == null) {
return;
}
- int i = startIndexInclusive < 0 ? 0 : startIndexInclusive;
+ int i = Math.max(startIndexInclusive, 0);
int j = Math.min(array.length, endIndexExclusive) - 1;
boolean tmp;
while (j > i) {
@@ -6570,7 +6570,7 @@
if (array == null) {
return;
}
- int i = startIndexInclusive < 0 ? 0 : startIndexInclusive;
+ int i = Math.max(startIndexInclusive, 0);
int j = Math.min(array.length, endIndexExclusive) - 1;
byte tmp;
while (j > i) {
@@ -6617,7 +6617,7 @@
if (array == null) {
return;
}
- int i = startIndexInclusive < 0 ? 0 : startIndexInclusive;
+ int i = Math.max(startIndexInclusive, 0);
int j = Math.min(array.length, endIndexExclusive) - 1;
char tmp;
while (j > i) {
@@ -6664,7 +6664,7 @@
if (array == null) {
return;
}
- int i = startIndexInclusive < 0 ? 0 : startIndexInclusive;
+ int i = Math.max(startIndexInclusive, 0);
int j = Math.min(array.length, endIndexExclusive) - 1;
double tmp;
while (j > i) {
@@ -6711,7 +6711,7 @@
if (array == null) {
return;
}
- int i = startIndexInclusive < 0 ? 0 : startIndexInclusive;
+ int i = Math.max(startIndexInclusive, 0);
int j = Math.min(array.length, endIndexExclusive) - 1;
float tmp;
while (j > i) {
@@ -6758,7 +6758,7 @@
if (array == null) {
return;
}
- int i = startIndexInclusive < 0 ? 0 : startIndexInclusive;
+ int i = Math.max(startIndexInclusive, 0);
int j = Math.min(array.length, endIndexExclusive) - 1;
int tmp;
while (j > i) {
@@ -6805,7 +6805,7 @@
if (array == null) {
return;
}
- int i = startIndexInclusive < 0 ? 0 : startIndexInclusive;
+ int i = Math.max(startIndexInclusive, 0);
int j = Math.min(array.length, endIndexExclusive) - 1;
long tmp;
while (j > i) {
@@ -6856,7 +6856,7 @@
if (array == null) {
return;
}
- int i = startIndexInclusive < 0 ? 0 : startIndexInclusive;
+ int i = Math.max(startIndexInclusive, 0);
int j = Math.min(array.length, endIndexExclusive) - 1;
Object tmp;
while (j > i) {
@@ -6903,7 +6903,7 @@
if (array == null) {
return;
}
- int i = startIndexInclusive < 0 ? 0 : startIndexInclusive;
+ int i = Math.max(startIndexInclusive, 0);
int j = Math.min(array.length, endIndexExclusive) - 1;
short tmp;
while (j > i) {
diff --git a/src/main/java/org/apache/commons/lang3/Conversion.java b/src/main/java/org/apache/commons/lang3/Conversion.java
index 18873d9..e710701 100644
--- a/src/main/java/org/apache/commons/lang3/Conversion.java
+++ b/src/main/java/org/apache/commons/lang3/Conversion.java
@@ -1534,7 +1534,7 @@
if (nBytes > 16) {
throw new IllegalArgumentException("nBytes is greater than 16");
}
- longToByteArray(src.getMostSignificantBits(), 0, dst, dstPos, nBytes > 8 ? 8 : nBytes);
+ longToByteArray(src.getMostSignificantBits(), 0, dst, dstPos, Math.min(nBytes, 8));
if (nBytes >= 8) {
longToByteArray(src.getLeastSignificantBits(), 0, dst, dstPos + 8, nBytes - 8);
}
diff --git a/src/main/java/org/apache/commons/lang3/text/StrBuilder.java b/src/main/java/org/apache/commons/lang3/text/StrBuilder.java
index 21c88e4..0fabc10 100644
--- a/src/main/java/org/apache/commons/lang3/text/StrBuilder.java
+++ b/src/main/java/org/apache/commons/lang3/text/StrBuilder.java
@@ -2420,7 +2420,7 @@
* @return the first index of the character, or -1 if not found
*/
public int indexOf(final char ch, int startIndex) {
- startIndex = (startIndex < 0 ? 0 : startIndex);
+ startIndex = (Math.max(startIndex, 0));
if (startIndex >= size) {
return -1;
}
@@ -2456,7 +2456,7 @@
* @return the first index of the string, or -1 if not found
*/
public int indexOf(final String str, int startIndex) {
- startIndex = (startIndex < 0 ? 0 : startIndex);
+ startIndex = (Math.max(startIndex, 0));
if (str == null || startIndex >= size) {
return -1;
}
@@ -2511,7 +2511,7 @@
* @return the first index matched, or -1 if not found
*/
public int indexOf(final StrMatcher matcher, int startIndex) {
- startIndex = (startIndex < 0 ? 0 : startIndex);
+ startIndex = (Math.max(startIndex, 0));
if (matcher == null || startIndex >= size) {
return -1;
}
diff --git a/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java b/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java
index 888d3fb..48cd49b 100644
--- a/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java
+++ b/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java
@@ -214,7 +214,7 @@
if (tokenLen == 2) {
rule = TwoDigitYearField.INSTANCE;
} else {
- rule = selectNumberRule(Calendar.YEAR, tokenLen < 4 ? 4 : tokenLen);
+ rule = selectNumberRule(Calendar.YEAR, Math.max(tokenLen, 4));
}
if (c == 'Y') {
rule = new WeekYear((NumberRule) rule);