code: private Object convertListToArray(Class pType, List pList) {
          Class valueType = pType.getComponentType();
          Object ret = Array.newInstance(valueType, pList.size());
          int i = 0;
          for (Object value : pList) {
              if (value == null) {
                  if (!valueType.isPrimitive()) {
                      Array.set(ret,i++,null);
                  } else {
                      throw new IllegalArgumentException("Cannot use a null value in an array of type " + valueType.getSimpleName());
                  }
              } else {
                  if (valueType.isAssignableFrom(value.getClass())) {
                      // Can be set directly
                      Array.set(ret,i++,value);
                  } else {
                      // Try to convert from string
                      Array.set(ret,i++,convertFromString(valueType.getCanonicalName(), value.toString()));
                  }
              }
          }
          return ret;
      }
docs: Convert a list to an array of the given type