equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
1600 * @since 9 |
1600 * @since 9 |
1601 */ |
1601 */ |
1602 @SafeVarargs |
1602 @SafeVarargs |
1603 @SuppressWarnings("varargs") |
1603 @SuppressWarnings("varargs") |
1604 static <K, V> Map<K, V> ofEntries(Entry<? extends K, ? extends V>... entries) { |
1604 static <K, V> Map<K, V> ofEntries(Entry<? extends K, ? extends V>... entries) { |
1605 Objects.requireNonNull(entries); |
1605 if (entries.length == 0) { // implicit null check of entries |
1606 if (entries.length == 0) { |
|
1607 return ImmutableCollections.Map0.instance(); |
1606 return ImmutableCollections.Map0.instance(); |
1608 } else if (entries.length == 1) { |
1607 } else if (entries.length == 1) { |
1609 return new ImmutableCollections.Map1<>(entries[0].getKey(), |
1608 return new ImmutableCollections.Map1<>(entries[0].getKey(), |
1610 entries[0].getValue()); |
1609 entries[0].getValue()); |
1611 } else { |
1610 } else { |