ArrayUtil { public static int[] getDimensions(Object array) { int[] dimensions = new int[0]; Class<?> type = array.getClass(); while (type.isArray()) { int length = array != null ? Array.getLength(array) : 0; dimensions = Ints.concat(dimensions, new int[]{length}); array = length > 0 ? Array.get(array, 0) : null; type = type.getComponentType(); } return dimensions; }  static Object flatten(Object array); static Object unflatten(Object array, int[] dimensions); static int[] getDimensions(Object array); static Class<?> getType(Object array); static Object transformArray(Object array, Function<F, T> transform, Class<T> toType);  }
@Test(dataProvider = "dimensions") public void testGetDimensions(Object array, int[] dimensions) throws Exception { assertEquals(ArrayUtil.getDimensions(array), dimensions); }