/** * Returns an immutable list containing the given elements, in order. * * @throws NullPointerException if any element is null */ public static <E> ImmutableList<E> of(E e1, E e2, E e3, E e4, E e5) { return construct(e1, e2, e3, e4, e5); }
/** * Returns an immutable list containing the given elements, in order. * * @throws NullPointerException if any element is null */ public static <E> ImmutableList<E> of(E e1, E e2, E e3, E e4, E e5, E e6) { return construct(e1, e2, e3, e4, e5, e6); }
/** * Returns an immutable list containing the given elements, in order. * * @throws NullPointerException if any element is null */ public static <E> ImmutableList<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8) { return construct(e1, e2, e3, e4, e5, e6, e7, e8); }
/** * Returns an immutable list containing the given elements, in order. * * @throws NullPointerException if any element is null */ public static <E> ImmutableList<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7) { return construct(e1, e2, e3, e4, e5, e6, e7); }
/** * Returns an immutable list containing the given elements, in order. * * @throws NullPointerException if any element is null */ public static <E> ImmutableList<E> of(E e1, E e2, E e3, E e4) { return construct(e1, e2, e3, e4); }
/** * Returns an immutable list containing the given elements, in order. * * @throws NullPointerException if any element is null */ public static <E> ImmutableList<E> of( E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10) { return construct(e1, e2, e3, e4, e5, e6, e7, e8, e9, e10); }
/** * Returns an immutable list containing the given elements, in order. * * @throws NullPointerException if any element is null */ public static <E> ImmutableList<E> of( E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10, E e11) { return construct(e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11); }
/** * Returns an immutable list containing the given elements, in order. * * @throws NullPointerException if any element is null */ public static <E> ImmutableList<E> of(E e1, E e2) { return construct(e1, e2); }
/** * Returns an immutable list containing the given elements, in order. * * @throws NullPointerException if any element is null */ public static <E> ImmutableList<E> of(E e1, E e2, E e3) { return construct(e1, e2, e3); }
/** * Returns an immutable list containing the given elements, in order. * * @throws NullPointerException if any element is null */ public static <E> ImmutableList<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9) { return construct(e1, e2, e3, e4, e5, e6, e7, e8, e9); }
/** * Returns an immutable list containing the given elements, in order. * * @throws NullPointerException if any element is null */ public static <E> ImmutableList<E> of(E e1, E e2, E e3) { return construct(e1, e2, e3); }
/** * Returns an immutable list containing the given elements, in order. * * @throws NullPointerException if any element is null */ public static <E> ImmutableList<E> of( E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10) { return construct(e1, e2, e3, e4, e5, e6, e7, e8, e9, e10); }
/** * Returns an immutable list containing the given elements, in order. * * @throws NullPointerException if any element is null */ public static <E> ImmutableList<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7) { return construct(e1, e2, e3, e4, e5, e6, e7); }
/** * Returns an immutable list containing the given elements, in order. * * @throws NullPointerException if any element is null */ public static <E> ImmutableList<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9) { return construct(e1, e2, e3, e4, e5, e6, e7, e8, e9); }
/** * Returns an immutable list containing the given elements, in order. * * @throws NullPointerException if any element is null */ public static <E> ImmutableList<E> of(E e1, E e2, E e3, E e4) { return construct(e1, e2, e3, e4); }
/** * Returns an immutable list containing the given elements, in order. * * @throws NullPointerException if any element is null */ public static <E> ImmutableList<E> of( E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10, E e11) { return construct(e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11); }
/** * Returns an immutable list containing the given elements, in order. * * @throws NullPointerException if any element is null */ public static <E> ImmutableList<E> of(E e1, E e2, E e3, E e4, E e5, E e6) { return construct(e1, e2, e3, e4, e5, e6); }
/** * Returns an immutable list containing the given elements, in order. * * @throws NullPointerException if any element is null */ public static <E> ImmutableList<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8) { return construct(e1, e2, e3, e4, e5, e6, e7, e8); }
/** * Returns an immutable list containing the given elements, in order. * * @throws NullPointerException if any of {@code elements} is null * @since 3.0 */ public static <E> ImmutableList<E> copyOf(E[] elements) { switch (elements.length) { case 0: return of(); case 1: return of(elements[0]); default: return construct(elements.clone()); } }
/** * Returns an immutable list containing the given elements, in order. * * <p>Despite the method name, this method attempts to avoid actually copying the data when it is * safe to do so. The exact circumstances under which a copy will or will not be performed are * undocumented and subject to change. * * <p>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>This method is safe to use even when {@code elements} is a synchronized or concurrent * collection that is currently being modified by another thread. * * @throws NullPointerException if any of {@code elements} is null */ public static <E> ImmutableList<E> copyOf(Collection<? extends E> elements) { if (elements instanceof ImmutableCollection) { @SuppressWarnings("unchecked") // all supported methods are covariant ImmutableList<E> list = ((ImmutableCollection<E>) elements).asList(); return list.isPartialView() ? ImmutableList.<E>asImmutableList(list.toArray()) : list; } return construct(elements.toArray()); }