< prev index next >
src/java.base/share/classes/java/util/Map.java
Print this page
rev 47862 : imported patch immu0
*** 1284,1294 ****
* @return an empty {@code Map}
*
* @since 9
*/
static <K, V> Map<K, V> of() {
! return ImmutableCollections.Map0.instance();
}
/**
* Returns an immutable map containing a single mapping.
* See <a href="#immutable">Immutable Map Static Factory Methods</a> for details.
--- 1284,1294 ----
* @return an empty {@code Map}
*
* @since 9
*/
static <K, V> Map<K, V> of() {
! return ImmutableCollections.emptyMap();
}
/**
* Returns an immutable map containing a single mapping.
* See <a href="#immutable">Immutable Map Static Factory Methods</a> for details.
*** 1601,1611 ****
*/
@SafeVarargs
@SuppressWarnings("varargs")
static <K, V> Map<K, V> ofEntries(Entry<? extends K, ? extends V>... entries) {
if (entries.length == 0) { // implicit null check of entries
! return ImmutableCollections.Map0.instance();
} else if (entries.length == 1) {
return new ImmutableCollections.Map1<>(entries[0].getKey(),
entries[0].getValue());
} else {
Object[] kva = new Object[entries.length << 1];
--- 1601,1611 ----
*/
@SafeVarargs
@SuppressWarnings("varargs")
static <K, V> Map<K, V> ofEntries(Entry<? extends K, ? extends V>... entries) {
if (entries.length == 0) { // implicit null check of entries
! return ImmutableCollections.emptyMap();
} else if (entries.length == 1) {
return new ImmutableCollections.Map1<>(entries[0].getKey(),
entries[0].getValue());
} else {
Object[] kva = new Object[entries.length << 1];
< prev index next >