Class Maps
java.lang.Object
org.glassfish.jersey.internal.guava.Maps
Static utility methods pertaining to
Map
instances (including instances of
SortedMap
, BiMap
, etc.). Also see this class's counterparts
Lists
, Sets
and Queues
.
See the Guava User Guide article on
Maps
.
- Since:
- 2.0 (imported from Google Collections Library)
- Author:
- Kevin Bourrillion, Mike Bostock, Isaac Shum, Louis Wasserman
-
Method Summary
Modifier and TypeMethodDescriptionstatic <K,
V> Map.Entry<K, V> immutableEntry
(K key, V value) Returns an immutable map entry with the specified key and value.static <K,
V> HashMap<K, V> newHashMapWithExpectedSize
(int expectedSize) Creates aHashMap
instance, with a high enough "initial capacity" that it should holdexpectedSize
elements without growth.
-
Method Details
-
newHashMapWithExpectedSize
Creates aHashMap
instance, with a high enough "initial capacity" that it should holdexpectedSize
elements without growth. This behavior cannot be broadly guaranteed, but it is observed to be true for OpenJDK 1.6. It also can't be guaranteed that the method isn't inadvertently oversizing the returned map.- Parameters:
expectedSize
- the number of elements you expect to add to the returned map- Returns:
- a new, empty
HashMap
with enough capacity to holdexpectedSize
elements without resizing - Throws:
IllegalArgumentException
- ifexpectedSize
is negative
-
immutableEntry
Returns an immutable map entry with the specified key and value. TheMap.Entry.setValue(V)
operation throws anUnsupportedOperationException
.The returned entry is serializable.
- Parameters:
key
- the key to be associated with the returned entryvalue
- the value to be associated with the returned entry
-