/** * Returns an immutable list containing the given elements, in order. * * @throws NullPointerException if any of {@code elements} is null */ public static <E> ImmutableList<E> copyOf(Iterator<? extends E> elements) { return copyOfInternal(Lists.newArrayList(elements)); }
/** * Returns an immutable list containing the given elements, in order. * * @throws NullPointerException if any of {@code elements} is null */ public static <E> ImmutableList<E> copyOf(Iterator<? extends E> elements) { return copyOfInternal(Lists.newArrayList(elements)); }
/** * Returns an immutable list containing the given elements, in order. * * @throws NullPointerException if any of {@code elements} is null */ public static <E> ImmutableList<E> copyOf(Iterator<? extends E> elements) { return copyOfInternal(Lists.newArrayList(elements)); }
@SuppressWarnings("unchecked") Collection<? extends E> coll = (Collection<? extends E>) elements; return copyOfInternal(coll); } else { return copyOfInternal(Lists.newArrayList(elements));
@SuppressWarnings("unchecked") Collection<? extends E> coll = (Collection<? extends E>) elements; return copyOfInternal(coll); } else { return copyOfInternal(Lists.newArrayList(elements));
/** * Returns an immutable list containing the given elements, in order. Note * that if {@code list} is a {@code List<String>}, then {@code * ImmutableList.copyOf(list)} returns an {@code ImmutableList<String>} * containing each of the strings in {@code list}, while * ImmutableList.of(list)} returns an {@code ImmutableList<List<String>>} * containing one element (the given list itself). * * <p><b>Note:</b> Despite what the method name suggests, if {@code elements} * is an {@code ImmutableList}, no copy will actually be performed, and the * given list itself will be returned. * * @throws NullPointerException if any of {@code elements} is null */ public static <E> ImmutableList<E> copyOf(Iterable<? extends E> elements) { if (elements instanceof ImmutableList) { @SuppressWarnings("unchecked") // all supported methods are covariant ImmutableList<E> list = (ImmutableList<E>) elements; return list; } return copyOfInternal(Collections2.toCollection(elements)); }