code: private static int getDimensions(Type type) {
          int dimensions = 0;
          while (type instanceof GenericArrayType) {
              dimensions++;
              type = ((GenericArrayType) type).getGenericComponentType();
          }
          
          return dimensions;
      }
docs: Get the number of dimensions for the specified type.  If the type is
  a {@link GenericArrayType}, the dimensions will equal the number of
  actual dimensions.  Otherwise, 0 will be returned.
  
  @param type  The underlying type
  
  @return  The number of dimensions