org.biojava.utils
Class OverlayMap

java.lang.Object
  extended by java.util.AbstractMap
      extended by org.biojava.utils.OverlayMap
All Implemented Interfaces:
Map

public class OverlayMap
extends AbstractMap

Overlap one map onto another. This allows you to have a map with local values and default values. The local and default values are provided by a child and parent map.

Author:
Thomas Down, Matthew Pocock

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
OverlayMap(Map parent)
          Build a new map with default key-value pairs.
OverlayMap(Map parent, Map overlay)
          Build a new map with default key-value pairs.
 
Method Summary
 boolean containsKey(Object key)
           
 Set entrySet()
           
 Object get(Object key)
           
 Map getOverlayMap()
          Return the object containing the overlay mappings.
 Map getParentMap()
          Return the object containing the fallback mappings.
 Set keySet()
           
 Object put(Object key, Object value)
           
 
Methods inherited from class java.util.AbstractMap
clear, clone, containsValue, equals, hashCode, isEmpty, putAll, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OverlayMap

public OverlayMap(Map parent,
                  Map overlay)
Build a new map with default key-value pairs.

Parameters:
parent - the default fall-through Map
overlay - the overriding Map

OverlayMap

public OverlayMap(Map parent)
Build a new map with default key-value pairs.

Parameters:
parent - the default fall-through Map
Method Detail

getParentMap

public Map getParentMap()
Return the object containing the fallback mappings. This is the actual parent map, not a copy.

Returns:
the parent map

getOverlayMap

public Map getOverlayMap()
Return the object containing the overlay mappings. This is the actual child map, not a copy.

Returns:
the child map

get

public Object get(Object key)
Specified by:
get in interface Map
Overrides:
get in class AbstractMap

entrySet

public Set entrySet()
Specified by:
entrySet in interface Map
Specified by:
entrySet in class AbstractMap

keySet

public Set keySet()
Specified by:
keySet in interface Map
Overrides:
keySet in class AbstractMap

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map
Overrides:
containsKey in class AbstractMap

put

public Object put(Object key,
                  Object value)
Specified by:
put in interface Map
Overrides:
put in class AbstractMap