Refactor rename the variable name from 'clss' to 'clazz' (#1087)
This commit is contained in:
parent
9b8c8af570
commit
e208744651
|
@ -643,15 +643,15 @@ public class ArrayUtils {
|
||||||
* @param array the array to add the element to, may be {@code null}
|
* @param array the array to add the element to, may be {@code null}
|
||||||
* @param index the position of the new object
|
* @param index the position of the new object
|
||||||
* @param element the object to add
|
* @param element the object to add
|
||||||
* @param clss the type of the element being added
|
* @param clazz the type of the element being added
|
||||||
* @return A new array containing the existing elements and the new element
|
* @return A new array containing the existing elements and the new element
|
||||||
*/
|
*/
|
||||||
private static Object add(final Object array, final int index, final Object element, final Class<?> clss) {
|
private static Object add(final Object array, final int index, final Object element, final Class<?> clazz) {
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
if (index != 0) {
|
if (index != 0) {
|
||||||
throw new IndexOutOfBoundsException("Index: " + index + ", Length: 0");
|
throw new IndexOutOfBoundsException("Index: " + index + ", Length: 0");
|
||||||
}
|
}
|
||||||
final Object joinedArray = Array.newInstance(clss, 1);
|
final Object joinedArray = Array.newInstance(clazz, 1);
|
||||||
Array.set(joinedArray, 0, element);
|
Array.set(joinedArray, 0, element);
|
||||||
return joinedArray;
|
return joinedArray;
|
||||||
}
|
}
|
||||||
|
@ -659,7 +659,7 @@ public class ArrayUtils {
|
||||||
if (index > length || index < 0) {
|
if (index > length || index < 0) {
|
||||||
throw new IndexOutOfBoundsException("Index: " + index + ", Length: " + length);
|
throw new IndexOutOfBoundsException("Index: " + index + ", Length: " + length);
|
||||||
}
|
}
|
||||||
final Object result = Array.newInstance(clss, length + 1);
|
final Object result = Array.newInstance(clazz, length + 1);
|
||||||
System.arraycopy(array, 0, result, 0, index);
|
System.arraycopy(array, 0, result, 0, index);
|
||||||
Array.set(result, index, element);
|
Array.set(result, index, element);
|
||||||
if (index < length) {
|
if (index < length) {
|
||||||
|
@ -767,15 +767,15 @@ public class ArrayUtils {
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static <T> T[] add(final T[] array, final int index, final T element) {
|
public static <T> T[] add(final T[] array, final int index, final T element) {
|
||||||
final Class<T> clss;
|
final Class<T> clazz;
|
||||||
if (array != null) {
|
if (array != null) {
|
||||||
clss = getComponentType(array);
|
clazz = getComponentType(array);
|
||||||
} else if (element != null) {
|
} else if (element != null) {
|
||||||
clss = ObjectUtils.getClass(element);
|
clazz = ObjectUtils.getClass(element);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Array and element cannot both be null");
|
throw new IllegalArgumentException("Array and element cannot both be null");
|
||||||
}
|
}
|
||||||
return (T[]) add(array, index, element, clss);
|
return (T[]) add(array, index, element, clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue