获取数组对象的元素类型

@param array 数组对象
@return 元素类型
@since 3.2.2
438325
public static Class<?> getComponentType(Object array) {
		return null == array ? null : array.getClass().getComponentType();
	}
914408
public static <T, J extends Convertable<T>> ArrayList<T> convert(J[] array) {
        return convert(array == null ? null : Arrays.asList(array));
    }
384211
public final static Object toObjectArray(final Object array) {
        if (!array.getClass().isArray()) {
            return array;
        }
        final Class<?> clazz = PRIMITIVE_TO_OBJ.get(array.getClass().getComponentType());
        return setArray(clazz, array);
    }
105407
public static Boolean[] box(boolean[] array) {
        dbc.precondition(array != null, "cannot box a null boolean array");
        final Boolean[] result = new Boolean[array.length];
        for (int i = 0; i != result.length; ++i) {
            result[i] = array[i];
        }
        return result;
    }
1137926
public static int[][] toInt(double[][] array) {
        int[][] n = new int[array.length][array[0].length];
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[0].length; j++) {
                n[i][j] = (int) array[i][j];
            }
        }
        return n;
    }
57294
public static <T> T getLastElement(final T[] array) {

    return isNotEmpty(array) ? array[array.length - 1] : null;
  }
746331
private static ICondition[] toConditions( JsonArray array)
    {
    return
      IntStream.range( 0, array.size())
      .mapToObj( i -> asCondition( array.getJsonObject( i)))
      .collect( toList())
      .toArray( new ICondition[0]);
    }
351266
public static Object[] toObjectArray(Object array) {
        //fixme 以下写法太丑陋，其实可以简单实现
        if (!array.getClass().isArray()) {
            throw new IllegalArgumentException("入参必须是数组");
        }
        if (int[].class.isInstance(array)) {
            int[] intArr = int[].class.cast(array);
            Integer[] objArr = new Integer[intArr.length];
            for (int i = 0; i < intArr.length; i++) {
                objArr[i] = intArr[i];
            }
            return objArr;
        }
        if (long[].class.isInstance(array)) {
            long[] longArr = long[].class.cast(array);
            Long[] objArr = new Long[longArr.length];
            for (int i = 0; i < longArr.length; i++) {
                objArr[i] = longArr[i];
            }
            return objArr;
        }
        if (short[].class.isInstance(array)) {
            short[] arr = short[].class.cast(array);
            Short[] objArr = new Short[arr.length];
            for (int i = 0; i < arr.length; i++) {
                objArr[i] = arr[i];
            }
            return objArr;
        }
        if (float[].class.isInstance(array)) {
            float[] arr = float[].class.cast(array);
            Float[] objArr = new Float[arr.length];
            for (int i = 0; i < arr.length; i++) {
                objArr[i] = arr[i];
            }
            return objArr;
        }
        if (double[].class.isInstance(array)) {
            double[] arr = double[].class.cast(array);
            Double[] objArr = new Double[arr.length];
            for (int i = 0; i < arr.length; i++) {
                objArr[i] = arr[i];
            }
            return objArr;
        }
        if (char[].class.isInstance(array)) {
            char[] arr = char[].class.cast(array);
            Character[] objArr = new Character[arr.length];
            for (int i = 0; i < arr.length; i++) {
                objArr[i] = arr[i];
            }
            return objArr;
        }
        if (byte[].class.isInstance(array)) {
            byte[] arr = byte[].class.cast(array);
            Byte[] objArr = new Byte[arr.length];
            for (int i = 0; i < arr.length; i++) {
                objArr[i] = arr[i];
            }
            return objArr;
        }
        if (boolean[].class.isInstance(array)) {
            boolean[] arr = boolean[].class.cast(array);
            Boolean[] objArr = new Boolean[arr.length];
            for (int i = 0; i < arr.length; i++) {
                objArr[i] = arr[i];
            }
            return objArr;
        }
        return Object[].class.cast(array);
    }
1292520
public static Object toWrapperArray(Object array) {
    if (!array.getClass().isArray()) {
      throw new IllegalArgumentException("Must give array object.");
    }
    if (isPrimitiveArray(array.getClass())) {
      int length = Array.getLength(array);
      Object newArray = Array.newInstance(toWrapper(array.getClass().getComponentType()), length);
      for (int i = 0; i < length; i++) {
        Array.set(newArray, i, toWrapper(Array.get(array, i)));
      }
      return newArray;
    } else if (array.getClass().getComponentType().isArray()) {
      int length = Array.getLength(array);
      Object newArray = Array.newInstance(toWrapperArray(array.getClass().getComponentType()), length);
      for (int i = 0; i < length; i++) {
        Array.set(newArray, i, toWrapperArray(Array.get(array, i)));
      }
      return newArray;
    }
    return array;
  }
1213020
public static <T> List<T> arrayToList(T [] array) {
        return new ArrayList<T>(Arrays.asList(array));
    }
333359
public static String[] toStringArrayEL(Array array) {
	String[] arr = new String[array.size()];
	for (int i = 0; i < arr.length; i++) {
	    arr[i] = Caster.toString(array.get(i + 1, null), null);
	}

	return arr;
    }
554073
public static <T> Set<T> toSet(final T[] array) {

    if (isNotEmpty(array)) {
      Set<T> set = new HashSet<T>(array.length);
      for (T element : array) {
        set.add(element);
      }
      return set;
    } else {
      return new HashSet<T>(0);
    }
  }
1071561
public static <E> Optional<E> maybeFirst(E[] array) {
        return new MaybeFirstElement<E>().apply(new ArrayIterator<>(array));
    }
686092
public static <T extends Number> int[] asArray(final T... array) {
        int[] b = new int[array.length];
        for (int i = 0; i < b.length; i++) {
            b[i] = array[i].intValue();
        }
        return b;
    }
57264
public static long[] parseLongs(String[] array) {
    long[] result = new long[array.length];
    for (int i = 0; i < array.length; i++)
      result[i] = Long.parseLong(array[i]);
    return result;
  }
1327625
public static <T> T[] append(final T[] array, final T element) {

    Class<?> compType = getClassType(array, element);
    if (compType == null) {
      return null;
    }
    int newArrLength = array != null ? array.length + 1 : 1;
    @SuppressWarnings("unchecked")
    T[] newArray = (T[]) Array.newInstance(compType, newArrLength);
    if (array != null) {
      System.arraycopy(array, 0, newArray, 0, array.length);
    }
    newArray[newArray.length - 1] = element;
    return newArray;
  }
369011
public static String[] sortStringArray(String[] array) {
        if (isEmpty(array)) {
            return new String[0];
        }
        Arrays.sort(array);
        return array;
    }