< prev index next >
src/java.base/share/classes/java/util/List.java
Print this page
rev 47862 : imported patch immu0
rev 47863 : imported patch listn
*** 785,795 ****
* @return an empty {@code List}
*
* @since 9
*/
static <E> List<E> of() {
! return ImmutableCollections.List0.instance();
}
/**
* Returns an immutable list containing one element.
*
--- 785,795 ----
* @return an empty {@code List}
*
* @since 9
*/
static <E> List<E> of() {
! return ImmutableCollections.emptyList();
}
/**
* Returns an immutable list containing one element.
*
*** 801,811 ****
* @throws NullPointerException if the element is {@code null}
*
* @since 9
*/
static <E> List<E> of(E e1) {
! return new ImmutableCollections.List1<>(e1);
}
/**
* Returns an immutable list containing two elements.
*
--- 801,811 ----
* @throws NullPointerException if the element is {@code null}
*
* @since 9
*/
static <E> List<E> of(E e1) {
! return new ImmutableCollections.ListN<>(e1);
}
/**
* Returns an immutable list containing two elements.
*
*** 818,828 ****
* @throws NullPointerException if an element is {@code null}
*
* @since 9
*/
static <E> List<E> of(E e1, E e2) {
! return new ImmutableCollections.List2<>(e1, e2);
}
/**
* Returns an immutable list containing three elements.
*
--- 818,828 ----
* @throws NullPointerException if an element is {@code null}
*
* @since 9
*/
static <E> List<E> of(E e1, E e2) {
! return new ImmutableCollections.ListN<>(e1, e2);
}
/**
* Returns an immutable list containing three elements.
*
*** 1028,1042 ****
@SafeVarargs
@SuppressWarnings("varargs")
static <E> List<E> of(E... elements) {
switch (elements.length) { // implicit null check of elements
case 0:
! return ImmutableCollections.List0.instance();
! case 1:
! return new ImmutableCollections.List1<>(elements[0]);
! case 2:
! return new ImmutableCollections.List2<>(elements[0], elements[1]);
default:
return new ImmutableCollections.ListN<>(elements);
}
}
}
--- 1028,1038 ----
@SafeVarargs
@SuppressWarnings("varargs")
static <E> List<E> of(E... elements) {
switch (elements.length) { // implicit null check of elements
case 0:
! return ImmutableCollections.emptyList();
default:
return new ImmutableCollections.ListN<>(elements);
}
}
}
< prev index next >