Class LinkedSetMultimap<K,V>

java.lang.Object
com.atlassian.bamboo.utils.collection.multimap.LinkedSetMultimap<K,V>
All Implemented Interfaces:
ImmutableMultimap<K,V>, Multimap<K,V>

public final class LinkedSetMultimap<K,V> extends Object implements Multimap<K,V>
Implementation of a Multimap that uses a LinkedHashMap to store keys in insertion order and LinkedHashSet to maintain insertion order of values.
Since:
10.0
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a view of the mappings contained in this multimap as a map from each key to its corresponding values.
    void
     
    boolean
    Returns true if this multimap contains one or more keys to the specified value.
    Creates a deep copy of this multimap.
    static <K, V> LinkedSetMultimap<K,V>
     
    Returns a collection view of all key-value pairs contained in this multimap.
    boolean
     
    get(K key)
    Retrieves the collection of values associated with the specified key in this multimap.
    int
     
    Creates an inverse view of this multimap.
    boolean
    Returns true if this multimap contains no key-value mappings.
    Returns the set of keys contained in this multimap.
    void
    put(K key, V value)
    Associates the specified value with the specified key in this multimap.
    void
    putAll(K key, Collection<? extends V> values)
    Associates all of the values in the specified collection with the specified key in this multimap.
    void
    remove(K key, V value)
    Removes a single instance of the specified value from the multimap, if it is present.
    void
    removeAll(K key)
    Removes all the values associated with the specified key in this multimap.
    int
    Returns the total number of key-value pairs in the multimap.
    Returns a collection view of all values associated with keys in this multimap.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LinkedSetMultimap

      public LinkedSetMultimap()
  • Method Details

    • create

      public static <K, V> LinkedSetMultimap<K,V> create()
    • put

      public void put(K key, V value)
      Description copied from interface: Multimap
      Associates the specified value with the specified key in this multimap. If the multimap previously contained a mapping for the key, the new value is added to the collection of values mapped to that key.
      Specified by:
      put in interface Multimap<K,V>
      Parameters:
      key - key with which the specified value is to be associated
      value - value to be associated with the specified key
    • putAll

      public void putAll(K key, Collection<? extends V> values)
      Description copied from interface: Multimap
      Associates all of the values in the specified collection with the specified key in this multimap. If the multimap previously contained mappings for the key, the new values are added to the collection of values mapped to that key.
      Specified by:
      putAll in interface Multimap<K,V>
      Parameters:
      key - key with which the specified values are to be associated
      values - collection of values to be associated with the specified key
    • get

      public Collection<V> get(K key)
      Description copied from interface: Multimap
      Retrieves the collection of values associated with the specified key in this multimap.
      Specified by:
      get in interface ImmutableMultimap<K,V>
      Specified by:
      get in interface Multimap<K,V>
      Parameters:
      key - the key whose associated values are to be returned
      Returns:
      the collection of values associated with the specified key, or an empty collection if no values are associated with the key
    • remove

      public void remove(K key, V value)
      Description copied from interface: Multimap
      Removes a single instance of the specified value from the multimap, if it is present.
      Specified by:
      remove in interface Multimap<K,V>
      Parameters:
      key - key with which the specified value is associated
      value - value to be removed from the collection of values for the specified key
    • removeAll

      public void removeAll(K key)
      Description copied from interface: Multimap
      Removes all the values associated with the specified key in this multimap.
      Specified by:
      removeAll in interface Multimap<K,V>
      Parameters:
      key - key whose associated values are to be removed
    • containsKey

      public boolean containsKey(K key)
      Description copied from interface: Multimap
      Returns true if this multimap contains one or more keys to the specified value.
      Specified by:
      containsKey in interface ImmutableMultimap<K,V>
      Specified by:
      containsKey in interface Multimap<K,V>
      Parameters:
      key - key whose presence in this multimap is to be tested
      Returns:
      true if this multimap contains a mapping for the specified key
    • keySet

      public Set<K> keySet()
      Description copied from interface: Multimap
      Returns the set of keys contained in this multimap.
      Specified by:
      keySet in interface ImmutableMultimap<K,V>
      Specified by:
      keySet in interface Multimap<K,V>
      Returns:
      the set of keys contained in this multimap
    • values

      public Collection<V> values()
      Description copied from interface: Multimap
      Returns a collection view of all values associated with keys in this multimap.
      Specified by:
      values in interface ImmutableMultimap<K,V>
      Specified by:
      values in interface Multimap<K,V>
      Returns:
      a collection view of all values contained in this multimap
    • clear

      public void clear()
    • copy

      public LinkedSetMultimap<K,V> copy()
      Description copied from interface: Multimap
      Creates a deep copy of this multimap.
      Specified by:
      copy in interface ImmutableMultimap<K,V>
      Specified by:
      copy in interface Multimap<K,V>
      Returns:
      a new multimap instance containing the same key-value mappings as this multimap
    • size

      public int size()
      Description copied from interface: Multimap
      Returns the total number of key-value pairs in the multimap.
      Specified by:
      size in interface ImmutableMultimap<K,V>
      Specified by:
      size in interface Multimap<K,V>
      Returns:
      the total number of key-value pairs
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: Multimap
      Returns true if this multimap contains no key-value mappings.
      Specified by:
      isEmpty in interface ImmutableMultimap<K,V>
      Specified by:
      isEmpty in interface Multimap<K,V>
      Returns:
      true if this multimap contains no key-value mappings
    • asMap

      public Map<K,Collection<V>> asMap()
      Description copied from interface: Multimap
      Returns a view of the mappings contained in this multimap as a map from each key to its corresponding values.
      Specified by:
      asMap in interface ImmutableMultimap<K,V>
      Specified by:
      asMap in interface Multimap<K,V>
      Returns:
      a map view of the mappings contained in this multimap
    • entries

      public Collection<Map.Entry<K,V>> entries()
      Description copied from interface: Multimap
      Returns a collection view of all key-value pairs contained in this multimap. Each key-value pair is represented as a Map.Entry. If the multimap allows duplicate values, a separate Map.Entry will be included for each duplicate value.
      Specified by:
      entries in interface ImmutableMultimap<K,V>
      Specified by:
      entries in interface Multimap<K,V>
      Returns:
      a collection view of all key-value pairs contained in this multimap
    • inverse

      public LinkedSetMultimap<V,K> inverse()
      Description copied from interface: Multimap
      Creates an inverse view of this multimap. In the inverse multimap, each value in the original multimap becomes a key in the new multimap, and each key in the original becomes part of the set of values associated with the new key. The inverse multimap is also immutable.
      Specified by:
      inverse in interface ImmutableMultimap<K,V>
      Specified by:
      inverse in interface Multimap<K,V>
      Returns:
      a new Multimap instance where the roles of keys and values are swapped
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object