Class AbstractDecoratorCollectionMap<K,​V,​C extends java.util.Collection<V>>

    • Nested Class Summary

      • Nested classes/interfaces inherited from interface java.util.Map

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

    • Constructor Detail

      • AbstractDecoratorCollectionMap

        public AbstractDecoratorCollectionMap​(java.util.Map<K,​C> map)
        Map constructor.
        Parameters:
        map - The map this map should decorate.
        Throws:
        java.lang.NullPointerException - if the provided map is null.
    • Method Detail

      • getCollection

        public C getCollection​(K key)
        Description copied from interface: CollectionMap
        Retrieves the collection of values associated with the given key. If no collection of values is associated with the key, one will be created and added to the map.
        Specified by:
        getCollection in interface CollectionMap<K,​V,​C extends java.util.Collection<V>>
        Parameters:
        key - The key in the map.
        Returns:
        The collection associated with the given key
        See Also:
        CollectionMap.createCollection()
      • hasItems

        public boolean hasItems​(K key)
        Description copied from interface: CollectionMap
        Retrieves whether there are items in a collection associated with the key.
        Specified by:
        hasItems in interface CollectionMap<K,​V,​C extends java.util.Collection<V>>
        Parameters:
        key - The key in the map.
        Returns:
        true if there is at least one item associated with the key.
      • getItemCount

        public int getItemCount​(K key)
        Description copied from interface: CollectionMap
        Retrieves the number of values in the collection, if any, associated with the key.
        Specified by:
        getItemCount in interface CollectionMap<K,​V,​C extends java.util.Collection<V>>
        Parameters:
        key - The key in the map.
        Returns:
        The number of items associated with the key.
      • addItem

        public void addItem​(K key,
                            V value)
        Description copied from interface: CollectionMap
        Adds a value to the collection of values associated with the key. If no collection of values is associated with the key, one will be created and added to the map.
        Specified by:
        addItem in interface CollectionMap<K,​V,​C extends java.util.Collection<V>>
        Parameters:
        key - The key in the map.
        value - The value to store in the collection.
      • getItem

        public V getItem​(K key)
        Description copied from interface: CollectionMap
        Retrieves the first value from the collection of values, if any, associated with the key.
        Specified by:
        getItem in interface CollectionMap<K,​V,​C extends java.util.Collection<V>>
        Parameters:
        key - The key in the map.
        Returns:
        The first value in the collection, or null if there is no collection associated with the key or no values in the collection.
        See Also:
        CollectionMap.getCollection(Object)
      • getItems

        public java.lang.Iterable<V> getItems​(K key)
        Description copied from interface: CollectionMap
        Retrieves iterable access to all items, if any, associated with the given key
        Specified by:
        getItems in interface CollectionMap<K,​V,​C extends java.util.Collection<V>>
        Parameters:
        key - The key in the map.
        Returns:
        An object that will iterate all items, if any, associated with the given key.
      • removeItem

        public boolean removeItem​(K key,
                                  V value)
        Description copied from interface: CollectionMap
        Removes the first occurence of the given value from the collection of values, if any, associated with the key. If all items from the collection are removed, the collection itself is removed from the map.
        Specified by:
        removeItem in interface CollectionMap<K,​V,​C extends java.util.Collection<V>>
        Parameters:
        key - The key in the map.
        value - The item to be removed from the collection, if present.
        Returns:
        true if an item was removed as a result of this call.