ReflectionUtils { @Nonnull public static <T> List<T> toList(Object array) throws IllegalArgumentException { int length = Array.getLength(array); List<T> list = Lists.newArrayListWithCapacity(length); for (int i = 0; i < length; i++) { Object element = Array.get(array, i); list.add((T) toObject(element)); } return list; }  @Nonnull static String getCallerClassName(); @Nonnull static Class<?> getCallerClass(); static Package getCallerPackage(); static void assertArrayIndex(Object array, int index); static void assertArrayType(Object array); static void assertFieldMatchType(Object object, String fieldName, Class<?> expectedType); @Nonnull static List<T> toList(Object array); @Nonnull static Map<String, Object> readFieldsAsMap(Object object); static final String SUN_REFLECT_REFLECTION_CLASS_NAME; }
@Test public void testToList() { int[] intArray = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9}; List<Integer> list = ReflectionUtils.toList(intArray); Object expectedList = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9); Assert.assertEquals(expectedList, list); int[][] intIntArray = new int[][]{{1, 2, 3}, {4, 5, 6,}, {7, 8, 9}}; list = ReflectionUtils.toList(intIntArray); expectedList = Arrays.asList(Arrays.asList(1, 2, 3), Arrays.asList(4, 5, 6), Arrays.asList(7, 8, 9)); Assert.assertEquals(expectedList, list); }