Class CollectionMap

  • All Implemented Interfaces:
    Map

    public class CollectionMap
    extends Object
    implements Map
    A Map whose values are Collections.
    • Constructor Detail

      • CollectionMap

        public CollectionMap​(Class mapClass)
        Creates a CollectionMap backed by the given Map class.
        Parameters:
        mapClass - a Class that implements Map
      • CollectionMap

        public CollectionMap​(Class mapClass,
                             Class collectionClass)
      • CollectionMap

        public CollectionMap()
        Creates a CollectionMap.
    • Method Detail

      • addItem

        public void addItem​(Object key,
                            Object item)
        Adds the item to the Collection at the given key, creating a new Collection if necessary.
        Parameters:
        key - the key to the Collection to which the item should be added
        item - the item to add
      • removeItem

        public void removeItem​(Object key,
                               Object item)
      • clear

        public void clear()
        Specified by:
        clear in interface Map
      • addItems

        public void addItems​(Object key,
                             Collection items)
        Adds the items to the Collection at the given key, creating a new Collection if necessary.
        Parameters:
        key - the key to the Collection to which the items should be added
        items - the items to add
      • values

        public Collection values()
        Returns the values.
        Specified by:
        values in interface Map
        Returns:
        a view of the values, backed by this CollectionMap
      • keySet

        public Set keySet()
        Returns the keys.
        Specified by:
        keySet in interface Map
        Returns:
        a view of the keys, backed by this CollectionMap
      • size

        public int size()
        Returns the number of mappings.
        Specified by:
        size in interface Map
        Returns:
        the number of key-value pairs
      • containsKey

        public boolean containsKey​(Object key)
        Specified by:
        containsKey in interface Map
      • containsValue

        public boolean containsValue​(Object value)
        Specified by:
        containsValue in interface Map
      • entrySet

        public Set entrySet()
        Specified by:
        entrySet in interface Map
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface Map
      • putAll

        public void putAll​(Map map)
        Specified by:
        putAll in interface Map
      • getMap

        public Map getMap()