code: public static <T> List<T> wrap(final T source) {
          val list = new ArrayList<T>();
          if (source != null) {
              if (source instanceof Collection) {
                  val it = ((Collection) source).iterator();
                  while (it.hasNext()) {
                      list.add((T) it.next());
                  }
              } else if (source.getClass().isArray()) {
                  if (source.getClass().isAssignableFrom(byte[].class)) {
                      list.add(source);
                  } else {
                      val elements = Arrays.stream((Object[]) source).collect(Collectors.toList());
                      list.addAll((List) elements);
                  }
              } else {
                  list.add(source);
              }
          }
          return list;
      }
docs: Wraps a possibly null list in an immutable wrapper.
  
  @param <T>    the type parameter
  @param source list to wrap.
  @return the list