diff --git a/src/main/java/org/apache/commons/lang3/ArrayUtils.java b/src/main/java/org/apache/commons/lang3/ArrayUtils.java index 4ced70c2b..afcb27ff7 100644 --- a/src/main/java/org/apache/commons/lang3/ArrayUtils.java +++ b/src/main/java/org/apache/commons/lang3/ArrayUtils.java @@ -8055,18 +8055,18 @@ public class ArrayUtils { return result; } - + /** *
Inserts elements into an array at the given index (starting from zero).
- * + * *When an array is returned, it is always a new array.
- * + * ** ArrayUtils.insert(index, null, null) = null * ArrayUtils.insert(index, array, null) = cloned copy of 'array' * ArrayUtils.insert(index, null, values) = null *- * + * * @param index the position within {@code array} to insert the new values * @param array the array to insert the values into, may be {@code null} * @param values the new values to insert, may be {@code null} @@ -8075,7 +8075,7 @@ public class ArrayUtils { * and either {@code index < 0} or {@code index > array.length} * @since 3.6 */ - public static boolean[] insert(final int index, final boolean[] array, final boolean... values) { + public static boolean[] insert(final int index, final boolean[] array, final boolean... values) { if (array == null) { return null; } @@ -8085,9 +8085,9 @@ public class ArrayUtils { if (index < 0 || index > array.length) { throw new IndexOutOfBoundsException("Index: " + index + ", Length: " + array.length); } - + boolean[] result = new boolean[array.length + values.length]; - + System.arraycopy(values, 0, result, index, values.length); if (index > 0) { System.arraycopy(array, 0, result, 0, index); @@ -8097,19 +8097,18 @@ public class ArrayUtils { } return result; } - - + /** *
Inserts elements into an array at the given index (starting from zero).
- * + * *When an array is returned, it is always a new array.
- * + * ** ArrayUtils.insert(index, null, null) = null * ArrayUtils.insert(index, array, null) = cloned copy of 'array' * ArrayUtils.insert(index, null, values) = null *- * + * * @param index the position within {@code array} to insert the new values * @param array the array to insert the values into, may be {@code null} * @param values the new values to insert, may be {@code null} @@ -8118,7 +8117,7 @@ public class ArrayUtils { * and either {@code index < 0} or {@code index > array.length} * @since 3.6 */ - public static byte[] insert(final int index, final byte[] array, final byte... values) { + public static byte[] insert(final int index, final byte[] array, final byte... values) { if (array == null) { return null; } @@ -8128,9 +8127,9 @@ public class ArrayUtils { if (index < 0 || index > array.length) { throw new IndexOutOfBoundsException("Index: " + index + ", Length: " + array.length); } - + byte[] result = new byte[array.length + values.length]; - + System.arraycopy(values, 0, result, index, values.length); if (index > 0) { System.arraycopy(array, 0, result, 0, index); @@ -8140,19 +8139,18 @@ public class ArrayUtils { } return result; } - - + /** *
Inserts elements into an array at the given index (starting from zero).
- * + * *When an array is returned, it is always a new array.
- * + * ** ArrayUtils.insert(index, null, null) = null * ArrayUtils.insert(index, array, null) = cloned copy of 'array' * ArrayUtils.insert(index, null, values) = null *- * + * * @param index the position within {@code array} to insert the new values * @param array the array to insert the values into, may be {@code null} * @param values the new values to insert, may be {@code null} @@ -8161,7 +8159,7 @@ public class ArrayUtils { * and either {@code index < 0} or {@code index > array.length} * @since 3.6 */ - public static char[] insert(final int index, final char[] array, final char... values) { + public static char[] insert(final int index, final char[] array, final char... values) { if (array == null) { return null; } @@ -8171,9 +8169,9 @@ public class ArrayUtils { if (index < 0 || index > array.length) { throw new IndexOutOfBoundsException("Index: " + index + ", Length: " + array.length); } - + char[] result = new char[array.length + values.length]; - + System.arraycopy(values, 0, result, index, values.length); if (index > 0) { System.arraycopy(array, 0, result, 0, index); @@ -8182,20 +8180,19 @@ public class ArrayUtils { System.arraycopy(array, index, result, index + values.length, array.length - index); } return result; - } - - + } + /** *
Inserts elements into an array at the given index (starting from zero).
- * + * *When an array is returned, it is always a new array.
- * + * ** ArrayUtils.insert(index, null, null) = null * ArrayUtils.insert(index, array, null) = cloned copy of 'array' * ArrayUtils.insert(index, null, values) = null *- * + * * @param index the position within {@code array} to insert the new values * @param array the array to insert the values into, may be {@code null} * @param values the new values to insert, may be {@code null} @@ -8204,7 +8201,7 @@ public class ArrayUtils { * and either {@code index < 0} or {@code index > array.length} * @since 3.6 */ - public static double[] insert(final int index, final double[] array, final double... values) { + public static double[] insert(final int index, final double[] array, final double... values) { if (array == null) { return null; } @@ -8214,9 +8211,9 @@ public class ArrayUtils { if (index < 0 || index > array.length) { throw new IndexOutOfBoundsException("Index: " + index + ", Length: " + array.length); } - + double[] result = new double[array.length + values.length]; - + System.arraycopy(values, 0, result, index, values.length); if (index > 0) { System.arraycopy(array, 0, result, 0, index); @@ -8225,20 +8222,19 @@ public class ArrayUtils { System.arraycopy(array, index, result, index + values.length, array.length - index); } return result; - } - - + } + /** *
Inserts elements into an array at the given index (starting from zero).
- * + * *When an array is returned, it is always a new array.
- * + * ** ArrayUtils.insert(index, null, null) = null * ArrayUtils.insert(index, array, null) = cloned copy of 'array' * ArrayUtils.insert(index, null, values) = null *- * + * * @param index the position within {@code array} to insert the new values * @param array the array to insert the values into, may be {@code null} * @param values the new values to insert, may be {@code null} @@ -8247,7 +8243,7 @@ public class ArrayUtils { * and either {@code index < 0} or {@code index > array.length} * @since 3.6 */ - public static float[] insert(final int index, final float[] array, final float... values) { + public static float[] insert(final int index, final float[] array, final float... values) { if (array == null) { return null; } @@ -8257,9 +8253,9 @@ public class ArrayUtils { if (index < 0 || index > array.length) { throw new IndexOutOfBoundsException("Index: " + index + ", Length: " + array.length); } - + float[] result = new float[array.length + values.length]; - + System.arraycopy(values, 0, result, index, values.length); if (index > 0) { System.arraycopy(array, 0, result, 0, index); @@ -8268,19 +8264,19 @@ public class ArrayUtils { System.arraycopy(array, index, result, index + values.length, array.length - index); } return result; - } - + } + /** *
Inserts elements into an array at the given index (starting from zero).
- * + * *When an array is returned, it is always a new array.
- * + * ** ArrayUtils.insert(index, null, null) = null * ArrayUtils.insert(index, array, null) = cloned copy of 'array' * ArrayUtils.insert(index, null, values) = null *- * + * * @param index the position within {@code array} to insert the new values * @param array the array to insert the values into, may be {@code null} * @param values the new values to insert, may be {@code null} @@ -8289,7 +8285,7 @@ public class ArrayUtils { * and either {@code index < 0} or {@code index > array.length} * @since 3.6 */ - public static int[] insert(final int index, final int[] array, final int... values) { + public static int[] insert(final int index, final int[] array, final int... values) { if (array == null) { return null; } @@ -8299,9 +8295,9 @@ public class ArrayUtils { if (index < 0 || index > array.length) { throw new IndexOutOfBoundsException("Index: " + index + ", Length: " + array.length); } - + int[] result = new int[array.length + values.length]; - + System.arraycopy(values, 0, result, index, values.length); if (index > 0) { System.arraycopy(array, 0, result, 0, index); @@ -8310,19 +8306,19 @@ public class ArrayUtils { System.arraycopy(array, index, result, index + values.length, array.length - index); } return result; - } - + } + /** *
Inserts elements into an array at the given index (starting from zero).
- * + * *When an array is returned, it is always a new array.
- * + * ** ArrayUtils.insert(index, null, null) = null * ArrayUtils.insert(index, array, null) = cloned copy of 'array' * ArrayUtils.insert(index, null, values) = null *- * + * * @param index the position within {@code array} to insert the new values * @param array the array to insert the values into, may be {@code null} * @param values the new values to insert, may be {@code null} @@ -8331,7 +8327,7 @@ public class ArrayUtils { * and either {@code index < 0} or {@code index > array.length} * @since 3.6 */ - public static long[] insert(final int index, final long[] array, final long... values) { + public static long[] insert(final int index, final long[] array, final long... values) { if (array == null) { return null; } @@ -8341,9 +8337,9 @@ public class ArrayUtils { if (index < 0 || index > array.length) { throw new IndexOutOfBoundsException("Index: " + index + ", Length: " + array.length); } - + long[] result = new long[array.length + values.length]; - + System.arraycopy(values, 0, result, index, values.length); if (index > 0) { System.arraycopy(array, 0, result, 0, index); @@ -8352,20 +8348,19 @@ public class ArrayUtils { System.arraycopy(array, index, result, index + values.length, array.length - index); } return result; - } - - + } + /** *
Inserts elements into an array at the given index (starting from zero).
- * + * *When an array is returned, it is always a new array.
- * + * ** ArrayUtils.insert(index, null, null) = null * ArrayUtils.insert(index, array, null) = cloned copy of 'array' * ArrayUtils.insert(index, null, values) = null *- * + * * @param index the position within {@code array} to insert the new values * @param array the array to insert the values into, may be {@code null} * @param values the new values to insert, may be {@code null} @@ -8374,7 +8369,7 @@ public class ArrayUtils { * and either {@code index < 0} or {@code index > array.length} * @since 3.6 */ - public static short[] insert(final int index, final short[] array, final short... values) { + public static short[] insert(final int index, final short[] array, final short... values) { if (array == null) { return null; } @@ -8384,9 +8379,9 @@ public class ArrayUtils { if (index < 0 || index > array.length) { throw new IndexOutOfBoundsException("Index: " + index + ", Length: " + array.length); } - + short[] result = new short[array.length + values.length]; - + System.arraycopy(values, 0, result, index, values.length); if (index > 0) { System.arraycopy(array, 0, result, 0, index); @@ -8395,14 +8390,13 @@ public class ArrayUtils { System.arraycopy(array, index, result, index + values.length, array.length - index); } return result; - } - - + } + /** *
Inserts elements into an array at the given index (starting from zero).
- * + * *When an array is returned, it is always a new array.
- * + * ** ArrayUtils.insert(index, null, null) = null * ArrayUtils.insert(index, array, null) = cloned copy of 'array' @@ -8427,7 +8421,7 @@ public class ArrayUtils { * array to the caller. We also avoid relying on the type of the vararg * array, by inspecting the component type of 'array'. */ - + if (array == null) { return null; } @@ -8437,11 +8431,11 @@ public class ArrayUtils { if (index < 0 || index > array.length) { throw new IndexOutOfBoundsException("Index: " + index + ", Length: " + array.length); } - + final Class> type = array.getClass().getComponentType(); @SuppressWarnings("unchecked") // OK, because array and values are of type T T[] result = (T[]) Array.newInstance(type, array.length + values.length); - + System.arraycopy(values, 0, result, index, values.length); if (index > 0) { System.arraycopy(array, 0, result, 0, index); @@ -8450,5 +8444,5 @@ public class ArrayUtils { System.arraycopy(array, index, result, index + values.length, array.length - index); } return result; - } + } } diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java b/src/main/java/org/apache/commons/lang3/StringUtils.java index 98a2d0c47..bd660bcce 100644 --- a/src/main/java/org/apache/commons/lang3/StringUtils.java +++ b/src/main/java/org/apache/commons/lang3/StringUtils.java @@ -7560,7 +7560,7 @@ public class StringUtils { * @param maxWidth maximum length of result String, must be at least {@code abbrevMarker.length + 1} * @return abbreviated String, {@code null} if null String input * @throws IllegalArgumentException if the width is too small - * @since 3.5 + * @since 3.6 */ public static String abbreviate(final String str, final String abbrevMarker, final int maxWidth) { return abbreviate(str, abbrevMarker, 0, maxWidth); @@ -7601,7 +7601,7 @@ public class StringUtils { * @param maxWidth maximum length of result String, must be at least 4 * @return abbreviated String, {@code null} if null String input * @throws IllegalArgumentException if the width is too small - * @since 3.5 + * @since 3.6 */ public static String abbreviate(final String str, final String abbrevMarker, int offset, final int maxWidth) { if (isEmpty(str) || isEmpty(abbrevMarker)) { @@ -9137,8 +9137,7 @@ public class StringUtils { return str; } - - + /** *Converts a {@code CharSequence} into an array of code points.
* @@ -9162,14 +9161,14 @@ public class StringUtils { if (str.length() == 0) { return ArrayUtils.EMPTY_INT_ARRAY; } - + String s = str.toString(); int[] result = new int[s.codePointCount(0, s.length())]; int index = 0; for (int i = 0; i < result.length; i++) { result[i] = s.codePointAt(index); index += Character.charCount(result[i]); - } + } return result; - } + } }