edu.mit.csail.sdg.alloy4
Class ConstMap<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by edu.mit.csail.sdg.alloy4.ConstMap<K,V>
Type Parameters:
K - - the type of key
V - - the type of value
All Implemented Interfaces:
java.io.Serializable, java.util.Map<K,V>

public final class ConstMap<K,V>
extends java.util.AbstractMap<K,V>
implements java.io.Serializable

Immutable; implements a map based on hashCode() and equals(); null key and values are allowed.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Method Summary
 boolean containsKey(java.lang.Object key)
          Returns true if exists at least one (k, v) mapping where (k==null ? key==null : k.equals(key))
 boolean containsValue(java.lang.Object value)
          Returns true if exists at least one (k, v) mapping where (v==null ? value==null : v.equals(value))
 java.util.Set<java.util.Map.Entry<K,V>> entrySet()
          Returns an unmodifiable view of the mappings in this map.
 V get(java.lang.Object key)
          Returns the value associated with the key (or null if not found); null is also returned if the given key maps to null.
 java.util.Set<K> keySet()
          Returns an unmodifiable view of the keys in this map.
static
<K,V> ConstMap<K,V>
make()
          Returns an unmodifiable empty map.
static
<K,V> ConstMap<K,V>
make(java.util.Map<K,V> map)
          Returns an unmodifiable map with the same entries and traversal order as the given map.
 int size()
          Returns the number of (key, value) mapping in this map.
 java.util.Collection<V> values()
          Returns an unmodifiable view of the values in this map.
 
Methods inherited from class java.util.AbstractMap
clear, clone, equals, hashCode, isEmpty, put, putAll, remove, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

make

public static <K,V> ConstMap<K,V> make()
Returns an unmodifiable empty map.


make

public static <K,V> ConstMap<K,V> make(java.util.Map<K,V> map)
Returns an unmodifiable map with the same entries and traversal order as the given map. (If map==null, we'll return an unmodifiable empty map)


entrySet

public java.util.Set<java.util.Map.Entry<K,V>> entrySet()
Returns an unmodifiable view of the mappings in this map.

Specified by:
entrySet in interface java.util.Map<K,V>
Specified by:
entrySet in class java.util.AbstractMap<K,V>

keySet

public java.util.Set<K> keySet()
Returns an unmodifiable view of the keys in this map.

Specified by:
keySet in interface java.util.Map<K,V>
Overrides:
keySet in class java.util.AbstractMap<K,V>

values

public java.util.Collection<V> values()
Returns an unmodifiable view of the values in this map.

Specified by:
values in interface java.util.Map<K,V>
Overrides:
values in class java.util.AbstractMap<K,V>

size

public int size()
Returns the number of (key, value) mapping in this map.

Specified by:
size in interface java.util.Map<K,V>
Overrides:
size in class java.util.AbstractMap<K,V>

containsKey

public boolean containsKey(java.lang.Object key)
Returns true if exists at least one (k, v) mapping where (k==null ? key==null : k.equals(key))

Specified by:
containsKey in interface java.util.Map<K,V>
Overrides:
containsKey in class java.util.AbstractMap<K,V>

containsValue

public boolean containsValue(java.lang.Object value)
Returns true if exists at least one (k, v) mapping where (v==null ? value==null : v.equals(value))

Specified by:
containsValue in interface java.util.Map<K,V>
Overrides:
containsValue in class java.util.AbstractMap<K,V>

get

public V get(java.lang.Object key)
Returns the value associated with the key (or null if not found); null is also returned if the given key maps to null.

Specified by:
get in interface java.util.Map<K,V>
Overrides:
get in class java.util.AbstractMap<K,V>