Class MultiKeyConcurrentHashMap<K,​V>

java.lang.Object
com.sun.faces.util.MultiKeyConcurrentHashMap<K,​V>

public class MultiKeyConcurrentHashMap<K,​V>
extends Object
This code is based off the source for ConcurrentHashMap from JDK 5 with the ability of mapping multiple keys to a single value.
  • This Map implemenation does not support iteration through keys and/or values.
  • This Map implementation is NOT Serialziable.
  • This cannot be cast as a general Map implementation.
  • Constructor Details

    • MultiKeyConcurrentHashMap

      public MultiKeyConcurrentHashMap​(int initialCapacity, float loadFactor, int concurrencyLevel)
      Creates a new, empty map with the specified initial capacity, load factor, and concurrency level.
      Parameters:
      initialCapacity - the initial capacity. The implementation performs internal sizing to accommodate this many elements.
      loadFactor - the load factor threshold, used to control resizing. Resizing may be performed when the average number of elements per bin exceeds this threshold.
      concurrencyLevel - the estimated number of concurrently updating threads. The implementation performs internal sizing to try to accommodate this many threads.
      Throws:
      IllegalArgumentException - if the initial capacity is negative or the load factor or concurrencyLevel are nonpositive.
    • MultiKeyConcurrentHashMap

      public MultiKeyConcurrentHashMap​(int initialCapacity)
      Creates a new, empty map with the specified initial capacity, and with default load factor and concurrencyLevel.
      Parameters:
      initialCapacity - the initial capacity. The implementation performs internal sizing to accommodate this many elements.
      Throws:
      IllegalArgumentException - if the initial capacity of elements is negative.
    • MultiKeyConcurrentHashMap

      public MultiKeyConcurrentHashMap()
      Creates a new, empty map with a default initial capacity, load factor, and concurrencyLevel.
  • Method Details

    • isEmpty

      public boolean isEmpty()
      See Also:
      Map.isEmpty()
    • size

      public int size()
      See Also:
      Map.size()
    • get

      public V get​(Object key)
      Returns the value to which the specified key is mapped in this table.
      Parameters:
      key - a key in the table.
      Returns:
      the value to which the key is mapped in this table; null if the key is not mapped to any value in this table.
      Throws:
      NullPointerException - if the key is null.
    • get

      public V get​(Object key1, Object key2)
      See Also:
      get(Object)
    • get

      public V get​(Object key1, Object key2, Object key3)
      See Also:
      get(Object)
    • get

      public V get​(Object key1, Object key2, Object key3, Object key4)
      See Also:
      get(Object)
    • containsKey

      public boolean containsKey​(Object key)
      Tests if the specified object is a key in this table.
      Parameters:
      key - possible key.
      Returns:
      true if and only if the specified object is a key in this table, as determined by the equals method; false otherwise.
      Throws:
      NullPointerException - if the key is null.
    • containsKey

      public boolean containsKey​(Object key1, Object key2)
      See Also:
      containsKey(Object)
    • containsKey

      public boolean containsKey​(Object key1, Object key2, Object key3)
      See Also:
      containsKey(Object)
    • containsKey

      public boolean containsKey​(Object key1, Object key2, Object key3, Object key4)
      See Also:
      containsKey(Object)
    • containsValue

      public boolean containsValue​(Object value)
      Returns true if this map maps one or more keys to the specified value. Note: This method requires a full internal traversal of the hash table, and so is much slower than method containsKey.
      Parameters:
      value - value whose presence in this map is to be tested.
      Returns:
      true if this map maps one or more keys to the specified value.
      Throws:
      NullPointerException - if the value is null.
    • contains

      public boolean contains​(Object value)
      Legacy method testing if some key maps into the specified value in this table. This method is identical in functionality to containsValue(java.lang.Object), and exists solely to ensure full compatibility with class Hashtable, which supported this method prior to introduction of the Java Collections framework.
      Parameters:
      value - a value to search for.
      Returns:
      true if and only if some key maps to the value argument in this table as determined by the equals method; false otherwise.
      Throws:
      NullPointerException - if the value is null.
    • put

      public V put​(K key, V value)
      Maps the specified key to the specified value in this table. Neither the key nor the value can be null.

      The value can be retrieved by calling the get method with a key that is equal to the original key.

      Parameters:
      key - the table key.
      value - the value.
      Returns:
      the previous value of the specified key in this table, or null if it did not have one.
      Throws:
      NullPointerException - if the key or value is null.
    • put

      public V put​(K key1, K key2, V value)
      See Also:
      put(Object, Object)
    • put

      public V put​(K key1, K key2, K key3, V value)
      See Also:
      put(Object, Object)
    • put

      public V put​(K key1, K key2, K key3, K key4, V value)
      See Also:
      put(Object, Object)
    • putIfAbsent

      public V putIfAbsent​(K key, V value)
      If the specified key is not already associated with a value, associate it with the given value. This is equivalent to
       if (!map.containsKey(key))
           return map.put(key, value);
       else
           return map.get(key);
       
      Except that the action is performed atomically.
      Parameters:
      key - key with which the specified value is to be associated.
      value - value to be associated with the specified key.
      Returns:
      previous value associated with specified key, or null if there was no mapping for key.
      Throws:
      NullPointerException - if the specified key or value is null.
    • putIfAbsent

      public V putIfAbsent​(K key1, K key2, V value)
      See Also:
      putIfAbsent(Object, Object)
    • putIfAbsent

      public V putIfAbsent​(K key1, K key2, K key3, V value)
      See Also:
      putIfAbsent(Object, Object)
    • putIfAbsent

      public V putIfAbsent​(K key1, K key2, K key3, K key4, V value)
      See Also:
      putIfAbsent(Object, Object)
    • remove

      public V remove​(K key)
      See Also:
      Map.remove(Object)
    • remove

      public V remove​(K key1, K key2)
      See Also:
      Map.remove(Object)
    • remove

      public V remove​(K key1, K key2, K key3)
      See Also:
      Map.remove(Object)
    • remove

      public V remove​(K key1, K key2, K key3, K key4)
      See Also:
      Map.remove(Object)
    • replace

      public boolean replace​(K key, V oldValue, V newValue)
      Replace entry for key only if currently mapped to given value. Acts as
       if (map.get(key).equals(oldValue)) {
           map.put(key, newValue);
           return true;
       } else
           return false;
       
      except that the action is performed atomically.
      Parameters:
      key - key with which the specified value is associated.
      oldValue - value expected to be associated with the specified key.
      newValue - value to be associated with the specified key.
      Returns:
      true if the value was replaced
      Throws:
      NullPointerException - if the specified key or values are null.
    • replace

      public V replace​(K key, V value)
      Replace entry for key only if currently mapped to some value. Acts as
        if ((map.containsKey(key)) {
           return map.put(key, value);
       } else return null;
       
      except that the action is performed atomically.
      Parameters:
      key - key with which the specified value is associated.
      value - value to be associated with the specified key.
      Returns:
      previous value associated with specified key, or null if there was no mapping for key.
      Throws:
      NullPointerException - if the specified key or value is null.
    • clear

      public void clear()
      Removes all mappings from this map.
    • keySet

      public Set<K> keySet()
      Unsupported
    • values

      public Collection<V> values()
      Unsupported.
    • entrySet

      public Set<Map.Entry<K,​V>> entrySet()
      Unsupported.