< prev index next >
src/java.base/share/classes/java/util/Set.java
Print this page
rev 47862 : imported patch immu0
@@ -446,11 +446,11 @@
* @return an empty {@code Set}
*
* @since 9
*/
static <E> Set<E> of() {
- return ImmutableCollections.Set0.instance();
+ return ImmutableCollections.emptySet();
}
/**
* Returns an immutable set containing one element.
* See <a href="#immutable">Immutable Set Static Factory Methods</a> for details.
@@ -478,11 +478,11 @@
* @throws NullPointerException if an element is {@code null}
*
* @since 9
*/
static <E> Set<E> of(E e1, E e2) {
- return new ImmutableCollections.Set2<>(e1, e2);
+ return new ImmutableCollections.SetN<>(e1, e2);
}
/**
* Returns an immutable set containing three elements.
* See <a href="#immutable">Immutable Set Static Factory Methods</a> for details.
@@ -689,15 +689,13 @@
@SafeVarargs
@SuppressWarnings("varargs")
static <E> Set<E> of(E... elements) {
switch (elements.length) { // implicit null check of elements
case 0:
- return ImmutableCollections.Set0.instance();
+ return ImmutableCollections.emptySet();
case 1:
return new ImmutableCollections.Set1<>(elements[0]);
- case 2:
- return new ImmutableCollections.Set2<>(elements[0], elements[1]);
default:
return new ImmutableCollections.SetN<>(elements);
}
}
}
< prev index next >