docs: @SuppressWarnings("unchecked")
      public static <E> E[] toArray(final List<E> list) {
          E[] array = null;
          if (list != null && list.size() > 0) {
              array = (E[]) Array.newInstance(list.get(0).getClass(), list.size());
              for (int i = 0; i < list.size(); i++) {
                  if (list.get(i) != null) {
                      array[i] = list.get(i);
                  } else {
                      array[i] = null;
                  }
              }
          }
          return array;
      }