code: public static <T> List<T> toImmutableList(final List<? extends T> list) {
      switch (list.size()) {
        case 0:
          return Collections.emptyList();
        case 1:
          return Collections.singletonList(list.get(0));
        default:
          return Collections.unmodifiableList(list);
      }
    }
docs: list to imuteable list.
  
  @param list list to convert
  @return imuteable list