com.google.inject.internal.util
Class Maps

java.lang.Object
  extended by com.google.inject.internal.util.Maps

public final class Maps
extends Object

Static utility methods pertaining to Map instances. Also see this class's counterparts Lists and Sets.

Author:
Kevin Bourrillion, Mike Bostock, Isaac Shum

Method Summary
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>
newHashMap()
          Creates a HashMap instance.
static
<K,V> IdentityHashMap<K,V>
newIdentityHashMap()
          Creates an IdentityHashMap instance.
static
<K,V> LinkedHashMap<K,V>
newLinkedHashMap()
          Creates an insertion-ordered LinkedHashMap instance.
static
<K extends Comparable,V>
TreeMap<K,V>
newTreeMap()
          Creates a TreeMap instance using the natural ordering of its elements.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newHashMap

public static <K,V> HashMap<K,V> newHashMap()
Creates a HashMap instance.

Note: if you don't actually need the resulting map to be mutable, use Collections.emptyMap() instead.

Returns:
a new, empty HashMap

newLinkedHashMap

public static <K,V> LinkedHashMap<K,V> newLinkedHashMap()
Creates an insertion-ordered LinkedHashMap instance.

Returns:
a new, empty LinkedHashMap

newTreeMap

public static <K extends Comparable,V> TreeMap<K,V> newTreeMap()
Creates a TreeMap instance using the natural ordering of its elements.

Returns:
a new, empty TreeMap

newIdentityHashMap

public static <K,V> IdentityHashMap<K,V> newIdentityHashMap()
Creates an IdentityHashMap instance.

Returns:
a new, empty IdentityHashMap

immutableEntry

public static <K,V> Map.Entry<K,V> immutableEntry(@Nullable
                                                  K key,
                                                  @Nullable
                                                  V value)
Returns an immutable map entry with the specified key and value. The Map.Entry.setValue(V) operation throws an UnsupportedOperationException.

The returned entry is serializable.

Parameters:
key - the key to be associated with the returned entry
value - the value to be associated with the returned entry


Copyright © 2006-2011 Google, Inc.. All Rights Reserved.