Class OverlayMap

  • All Implemented Interfaces:
    java.util.Map

    public class OverlayMap
    extends java.util.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

        java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,​V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,​V extends java.lang.Object>
      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Constructor Summary

      Constructors 
      Constructor Description
      OverlayMap​(java.util.Map parent)
      Build a new map with default key-value pairs.
      OverlayMap​(java.util.Map parent, java.util.Map overlay)
      Build a new map with default key-value pairs.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean containsKey​(java.lang.Object key)  
      java.util.Set entrySet()  
      java.lang.Object get​(java.lang.Object key)  
      java.util.Map getOverlayMap()
      Return the object containing the overlay mappings.
      java.util.Map getParentMap()
      Return the object containing the fallback mappings.
      java.util.Set keySet()  
      java.lang.Object put​(java.lang.Object key, java.lang.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
      • Methods inherited from interface java.util.Map

        compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
    • Constructor Detail

      • OverlayMap

        public OverlayMap​(java.util.Map parent,
                          java.util.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​(java.util.Map parent)
        Build a new map with default key-value pairs.
        Parameters:
        parent - the default fall-through Map
    • Method Detail

      • getParentMap

        public java.util.Map getParentMap()
        Return the object containing the fallback mappings. This is the actual parent map, not a copy.
        Returns:
        the parent map
      • getOverlayMap

        public java.util.Map getOverlayMap()
        Return the object containing the overlay mappings. This is the actual child map, not a copy.
        Returns:
        the child map
      • get

        public java.lang.Object get​(java.lang.Object key)
        Specified by:
        get in interface java.util.Map
        Overrides:
        get in class java.util.AbstractMap
      • entrySet

        public java.util.Set entrySet()
        Specified by:
        entrySet in interface java.util.Map
        Specified by:
        entrySet in class java.util.AbstractMap
      • keySet

        public java.util.Set keySet()
        Specified by:
        keySet in interface java.util.Map
        Overrides:
        keySet in class java.util.AbstractMap
      • containsKey

        public boolean containsKey​(java.lang.Object key)
        Specified by:
        containsKey in interface java.util.Map
        Overrides:
        containsKey in class java.util.AbstractMap
      • put

        public java.lang.Object put​(java.lang.Object key,
                                    java.lang.Object value)
        Specified by:
        put in interface java.util.Map
        Overrides:
        put in class java.util.AbstractMap