edu.rice.cs.plt.collect
Class SingletonMap<K,V>

java.lang.Object
  extended by edu.rice.cs.plt.collect.AbstractKeyBasedMap<K,V>
      extended by edu.rice.cs.plt.collect.SingletonMap<K,V>
All Implemented Interfaces:
LambdaMap<K,V>, Lambda<K,V>, Serializable, Map<K,V>

public class SingletonMap<K,V>
extends AbstractKeyBasedMap<K,V>
implements Serializable

An immutable LambdaMap containing a single entry.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class edu.rice.cs.plt.collect.AbstractKeyBasedMap
AbstractKeyBasedMap.EntrySet
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
SingletonMap(K key, V value)
           
 
Method Summary
 boolean containsKey(Object obj)
          Returns keySet().contains(key).
 boolean containsValue(Object obj)
          Returns IterUtil.contains(IterUtil.map(keySet(), this), val).
 V get(Object obj)
           
 boolean isEmpty()
          Returns keySet().isEmpty().
 PredicateSet<K> keySet()
           
static
<K,V> SingletonMap<K,V>
make(K key, V value)
          Call the constructor (allows type arguments to be inferred)
 int size()
          Returns keySet().size().
 Collection<V> values()
          Return a collection backed by IterUtil.map(keySet(), this).
 
Methods inherited from class edu.rice.cs.plt.collect.AbstractKeyBasedMap
clear, entrySet, equals, hashCode, mapEntryForKey, put, putAll, remove, toString, value
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SingletonMap

public SingletonMap(K key,
                    V value)
Method Detail

get

public V get(Object obj)
Specified by:
get in interface Map<K,V>
Specified by:
get in class AbstractKeyBasedMap<K,V>

keySet

public PredicateSet<K> keySet()
Specified by:
keySet in interface LambdaMap<K,V>
Specified by:
keySet in interface Map<K,V>
Specified by:
keySet in class AbstractKeyBasedMap<K,V>

size

public int size()
Description copied from class: AbstractKeyBasedMap
Returns keySet().size().

Specified by:
size in interface Map<K,V>
Overrides:
size in class AbstractKeyBasedMap<K,V>

isEmpty

public boolean isEmpty()
Description copied from class: AbstractKeyBasedMap
Returns keySet().isEmpty().

Specified by:
isEmpty in interface Map<K,V>
Overrides:
isEmpty in class AbstractKeyBasedMap<K,V>

containsKey

public boolean containsKey(Object obj)
Description copied from class: AbstractKeyBasedMap
Returns keySet().contains(key).

Specified by:
containsKey in interface Map<K,V>
Overrides:
containsKey in class AbstractKeyBasedMap<K,V>

containsValue

public boolean containsValue(Object obj)
Description copied from class: AbstractKeyBasedMap
Returns IterUtil.contains(IterUtil.map(keySet(), this), val).

Specified by:
containsValue in interface Map<K,V>
Overrides:
containsValue in class AbstractKeyBasedMap<K,V>

values

public Collection<V> values()
Description copied from class: AbstractKeyBasedMap
Return a collection backed by IterUtil.map(keySet(), this).

Specified by:
values in interface Map<K,V>
Overrides:
values in class AbstractKeyBasedMap<K,V>

make

public static <K,V> SingletonMap<K,V> make(K key,
                                           V value)
Call the constructor (allows type arguments to be inferred)