Use our own APIs.

This commit is contained in:
Gary Gregory 2019-09-11 11:15:21 -04:00
parent 975df007a5
commit d572b37a7d
2 changed files with 46 additions and 47 deletions

View File

@ -1872,7 +1872,7 @@ public static void reverse(final short[] array, final int startIndexInclusive, f
* @since 3.5
*/
public static void swap(final Object[] array, final int offset1, final int offset2) {
if (array == null || array.length == 0) {
if (isEmpty(array)) {
return;
}
swap(array, offset1, offset2, 1);
@ -1901,7 +1901,7 @@ public static void swap(final Object[] array, final int offset1, final int offse
* @since 3.5
*/
public static void swap(final long[] array, final int offset1, final int offset2) {
if (array == null || array.length == 0) {
if (isEmpty(array)) {
return;
}
swap(array, offset1, offset2, 1);
@ -1929,7 +1929,7 @@ public static void swap(final long[] array, final int offset1, final int offset2
* @since 3.5
*/
public static void swap(final int[] array, final int offset1, final int offset2) {
if (array == null || array.length == 0) {
if (isEmpty(array)) {
return;
}
swap(array, offset1, offset2, 1);
@ -1957,7 +1957,7 @@ public static void swap(final int[] array, final int offset1, final int offset2)
* @since 3.5
*/
public static void swap(final short[] array, final int offset1, final int offset2) {
if (array == null || array.length == 0) {
if (isEmpty(array)) {
return;
}
swap(array, offset1, offset2, 1);
@ -1985,7 +1985,7 @@ public static void swap(final short[] array, final int offset1, final int offset
* @since 3.5
*/
public static void swap(final char[] array, final int offset1, final int offset2) {
if (array == null || array.length == 0) {
if (isEmpty(array)) {
return;
}
swap(array, offset1, offset2, 1);
@ -2013,7 +2013,7 @@ public static void swap(final char[] array, final int offset1, final int offset2
* @since 3.5
*/
public static void swap(final byte[] array, final int offset1, final int offset2) {
if (array == null || array.length == 0) {
if (isEmpty(array)) {
return;
}
swap(array, offset1, offset2, 1);
@ -2041,7 +2041,7 @@ public static void swap(final byte[] array, final int offset1, final int offset2
* @since 3.5
*/
public static void swap(final double[] array, final int offset1, final int offset2) {
if (array == null || array.length == 0) {
if (isEmpty(array)) {
return;
}
swap(array, offset1, offset2, 1);
@ -2069,7 +2069,7 @@ public static void swap(final double[] array, final int offset1, final int offse
* @since 3.5
*/
public static void swap(final float[] array, final int offset1, final int offset2) {
if (array == null || array.length == 0) {
if (isEmpty(array)) {
return;
}
swap(array, offset1, offset2, 1);
@ -2097,7 +2097,7 @@ public static void swap(final float[] array, final int offset1, final int offset
* @since 3.5
*/
public static void swap(final boolean[] array, final int offset1, final int offset2) {
if (array == null || array.length == 0) {
if (isEmpty(array)) {
return;
}
swap(array, offset1, offset2, 1);
@ -2128,7 +2128,7 @@ public static void swap(final boolean[] array, final int offset1, final int offs
* @since 3.5
*/
public static void swap(final boolean[] array, int offset1, int offset2, int len) {
if (array == null || array.length == 0 || offset1 >= array.length || offset2 >= array.length) {
if (isEmpty(array) || offset1 >= array.length || offset2 >= array.length) {
return;
}
if (offset1 < 0) {
@ -2170,7 +2170,7 @@ public static void swap(final boolean[] array, int offset1, int offset2, int len
* @since 3.5
*/
public static void swap(final byte[] array, int offset1, int offset2, int len) {
if (array == null || array.length == 0 || offset1 >= array.length || offset2 >= array.length) {
if (isEmpty(array) || offset1 >= array.length || offset2 >= array.length) {
return;
}
if (offset1 < 0) {
@ -2212,7 +2212,7 @@ public static void swap(final byte[] array, int offset1, int offset2, int len) {
* @since 3.5
*/
public static void swap(final char[] array, int offset1, int offset2, int len) {
if (array == null || array.length == 0 || offset1 >= array.length || offset2 >= array.length) {
if (isEmpty(array) || offset1 >= array.length || offset2 >= array.length) {
return;
}
if (offset1 < 0) {
@ -2254,7 +2254,7 @@ public static void swap(final char[] array, int offset1, int offset2, int len) {
* @since 3.5
*/
public static void swap(final double[] array, int offset1, int offset2, int len) {
if (array == null || array.length == 0 || offset1 >= array.length || offset2 >= array.length) {
if (isEmpty(array) || offset1 >= array.length || offset2 >= array.length) {
return;
}
if (offset1 < 0) {
@ -2296,7 +2296,7 @@ public static void swap(final double[] array, int offset1, int offset2, int len
* @since 3.5
*/
public static void swap(final float[] array, int offset1, int offset2, int len) {
if (array == null || array.length == 0 || offset1 >= array.length || offset2 >= array.length) {
if (isEmpty(array) || offset1 >= array.length || offset2 >= array.length) {
return;
}
if (offset1 < 0) {
@ -2339,7 +2339,7 @@ public static void swap(final float[] array, int offset1, int offset2, int len)
* @since 3.5
*/
public static void swap(final int[] array, int offset1, int offset2, int len) {
if (array == null || array.length == 0 || offset1 >= array.length || offset2 >= array.length) {
if (isEmpty(array) || offset1 >= array.length || offset2 >= array.length) {
return;
}
if (offset1 < 0) {
@ -2381,7 +2381,7 @@ public static void swap(final int[] array, int offset1, int offset2, int len) {
* @since 3.5
*/
public static void swap(final long[] array, int offset1, int offset2, int len) {
if (array == null || array.length == 0 || offset1 >= array.length || offset2 >= array.length) {
if (isEmpty(array) || offset1 >= array.length || offset2 >= array.length) {
return;
}
if (offset1 < 0) {
@ -2423,7 +2423,7 @@ public static void swap(final long[] array, int offset1, int offset2, int len)
* @since 3.5
*/
public static void swap(final Object[] array, int offset1, int offset2, int len) {
if (array == null || array.length == 0 || offset1 >= array.length || offset2 >= array.length) {
if (isEmpty(array) || offset1 >= array.length || offset2 >= array.length) {
return;
}
if (offset1 < 0) {
@ -2465,7 +2465,7 @@ public static void swap(final Object[] array, int offset1, int offset2, int len
* @since 3.5
*/
public static void swap(final short[] array, int offset1, int offset2, int len) {
if (array == null || array.length == 0 || offset1 >= array.length || offset2 >= array.length) {
if (isEmpty(array) || offset1 >= array.length || offset2 >= array.length) {
return;
}
if (offset1 < 0) {

View File

@ -426,7 +426,7 @@ private static String appendIfMissing(final String str, final CharSequence suffi
if (str == null || isEmpty(suffix) || endsWith(str, suffix, ignoreCase)) {
return str;
}
if (suffixes != null && suffixes.length > 0) {
if (ArrayUtils.isNotEmpty(suffixes)) {
for (final CharSequence s : suffixes) {
if (endsWith(str, s, ignoreCase)) {
return str;
@ -534,8 +534,8 @@ public static String appendIfMissingIgnoreCase(final String str, final CharSeque
* @since 2.0
*/
public static String capitalize(final String str) {
int strLen;
if (str == null || (strLen = str.length()) == 0) {
int strLen = length(str);
if (strLen == 0) {
return str;
}
@ -2009,7 +2009,7 @@ public static byte[] getBytes(final String string, final String charset) throws
* @since 2.4
*/
public static String getCommonPrefix(final String... strs) {
if (strs == null || strs.length == 0) {
if (ArrayUtils.isEmpty(strs)) {
return EMPTY;
}
final int smallestIndexOfDiff = indexOfDifference(strs);
@ -2905,7 +2905,7 @@ public static int indexOfAnyBut(final CharSequence seq, final CharSequence searc
* @since 3.0 Changed signature from indexOfDifference(String...) to indexOfDifference(CharSequence...)
*/
public static int indexOfDifference(final CharSequence... css) {
if (css == null || css.length <= 1) {
if (ArrayUtils.getLength(css) <= 1) {
return INDEX_NOT_FOUND;
}
boolean anyStringNull = false;
@ -3176,7 +3176,7 @@ public static boolean isAllEmpty(final CharSequence... css) {
* @since 3.0 Changed signature from isAllLowerCase(String) to isAllLowerCase(CharSequence)
*/
public static boolean isAllLowerCase(final CharSequence cs) {
if (cs == null || isEmpty(cs)) {
if (isEmpty(cs)) {
return false;
}
final int sz = cs.length();
@ -3211,7 +3211,7 @@ public static boolean isAllLowerCase(final CharSequence cs) {
* @since 3.0 Changed signature from isAllUpperCase(String) to isAllUpperCase(CharSequence)
*/
public static boolean isAllUpperCase(final CharSequence cs) {
if (cs == null || isEmpty(cs)) {
if (isEmpty(cs)) {
return false;
}
final int sz = cs.length();
@ -3491,8 +3491,8 @@ public static boolean isAsciiPrintable(final CharSequence cs) {
* @since 3.0 Changed signature from isBlank(String) to isBlank(CharSequence)
*/
public static boolean isBlank(final CharSequence cs) {
int strLen;
if (cs == null || (strLen = cs.length()) == 0) {
int strLen = length(cs);
if (strLen == 0) {
return true;
}
for (int i = 0; i < strLen; i++) {
@ -4388,6 +4388,7 @@ public static String join(final List<?> list, final String separator, final int
return join(subList.iterator(), separator);
}
/**
* <p>
* Joins the elements of the provided array into a single String containing the provided list of elements.
@ -4420,7 +4421,6 @@ public static String join(final long[] array, final char separator) {
return join(array, separator, 0, array.length);
}
/**
* <p>
* Joins the elements of the provided array into a single String containing the provided list of elements.
@ -4721,6 +4721,7 @@ public static String join(final short[] array, final char separator, final int s
return buf.toString();
}
// Joining
//-----------------------------------------------------------------------
/**
@ -4750,7 +4751,6 @@ public static <T> String join(final T... elements) {
return join(elements, null);
}
/**
* <p>Joins the elements of the provided varargs into a
* single String containing the provided elements.</p>
@ -5679,7 +5679,7 @@ private static String prependIfMissing(final String str, final CharSequence pref
if (str == null || isEmpty(prefix) || startsWith(str, prefix, ignoreCase)) {
return str;
}
if (prefixes != null && prefixes.length > 0) {
if (ArrayUtils.isNotEmpty(prefixes)) {
for (final CharSequence p : prefixes) {
if (startsWith(str, p, ignoreCase)) {
return str;
@ -6237,6 +6237,9 @@ public static String repeat(final String str, final int repeat) {
}
}
// Conversion
//-----------------------------------------------------------------------
/**
* <p>Repeat a String {@code repeat} times to form a
* new String, with a String separator injected each time. </p>
@ -6266,9 +6269,6 @@ public static String repeat(final String str, final String separator, final int
return removeEnd(result, separator);
}
// Conversion
//-----------------------------------------------------------------------
/**
* <p>Replaces all occurrences of a String within another String.</p>
*
@ -6636,8 +6636,7 @@ private static String replaceEach(
// mchyzer Performance note: This creates very few new objects (one major goal)
// let me know if there are performance requests, we can create a harness to measure
if (text == null || text.isEmpty() || searchList == null ||
searchList.length == 0 || replacementList == null || replacementList.length == 0) {
if (isEmpty(text) || ArrayUtils.isEmpty(searchList) || ArrayUtils.isEmpty(replacementList)) {
return text;
}
@ -8257,8 +8256,8 @@ public static String[] stripAll(final String[] strs, final String stripChars) {
* @return the stripped String, {@code null} if null String input
*/
public static String stripEnd(final String str, final String stripChars) {
int end;
if (str == null || (end = str.length()) == 0) {
int end = length(str);
if (end == 0) {
return str;
}
@ -8301,8 +8300,8 @@ public static String stripEnd(final String str, final String stripChars) {
* @return the stripped String, {@code null} if null String input
*/
public static String stripStart(final String str, final String stripChars) {
int strLen;
if (str == null || (strLen = str.length()) == 0) {
int strLen = length(str);
if (strLen == 0) {
return str;
}
int start = 0;
@ -8533,6 +8532,9 @@ public static String substringAfter(final String str, final String separator) {
return str.substring(pos + separator.length());
}
// startsWith
//-----------------------------------------------------------------------
/**
* <p>Gets the substring after the last occurrence of a separator.
* The separator is not returned.</p>
@ -8576,9 +8578,6 @@ public static String substringAfterLast(final String str, final String separator
return str.substring(pos + separator.length());
}
// startsWith
//-----------------------------------------------------------------------
// SubStringAfter/SubStringBefore
//-----------------------------------------------------------------------
/**
@ -8687,6 +8686,9 @@ public static String substringBetween(final String str, final String tag) {
return substringBetween(str, tag, tag);
}
// endsWith
//-----------------------------------------------------------------------
/**
* <p>Gets the String that is nested in between two Strings.
* Only the first match is returned.</p>
@ -8728,9 +8730,6 @@ public static String substringBetween(final String str, final String open, final
return null;
}
// endsWith
//-----------------------------------------------------------------------
/**
* <p>Searches a String for substrings delimited by a start and end tag,
* returning all matching substrings in an array.</p>
@ -9147,8 +9146,8 @@ public static String truncate(final String str, final int offset, final int maxW
* @since 2.0
*/
public static String uncapitalize(final String str) {
int strLen;
if (str == null || (strLen = str.length()) == 0) {
int strLen = length(str);
if (strLen == 0) {
return str;
}