Class Maps
- java.lang.Object
-
- org.glassfish.jersey.internal.guava.Maps
-
public final class Maps extends Object
Static utility methods pertaining toMapinstances (including instances ofSortedMap,BiMap, etc.). Also see this class's counterpartsLists,SetsandQueues.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
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <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 aHashMapinstance, with a high enough "initial capacity" that it should holdexpectedSizeelements without growth.
-
-
-
Method Detail
-
newHashMapWithExpectedSize
public static <K,V> HashMap<K,V> newHashMapWithExpectedSize(int expectedSize)
Creates aHashMapinstance, with a high enough "initial capacity" that it should holdexpectedSizeelements 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
HashMapwith enough capacity to holdexpectedSizeelements without resizing - Throws:
IllegalArgumentException- ifexpectedSizeis negative
-
immutableEntry
public static <K,V> Map.Entry<K,V> immutableEntry(K key, V value)
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
-
-