org.gcube.vremanagement.resourcemanager.impl.resources.types
Class MultiKeysMap<K1,K2,V>

java.lang.Object
  extended by org.gcube.vremanagement.resourcemanager.impl.resources.types.MultiKeysMap<K1,K2,V>
All Implemented Interfaces:
java.lang.Iterable<V>

public class MultiKeysMap<K1,K2,V>
extends java.lang.Object
implements java.lang.Iterable<V>

A thread-safe Map with multiple keys allowing multiple values per key

Author:
Manuele Simi (ISTI-CNR)

Constructor Summary
MultiKeysMap()
           
 
Method Summary
 void clean()
          Removes all mapping from this maps
 java.util.Set<V> getValuesByPrimaryKey(K1 key)
          Returns the values to which this map maps the specified primary key
 java.util.Set<V> getValuesBySecondaryKey(K2 key)
          Returns the values to which this map maps the specified primary key
 java.util.Iterator<V> iterator()
          
 java.util.Set<K1> primaryKeySet()
          Returns a set view of the primary keys contained in this map
 void put(K1 key1, K2 key2, V value)
          Associates the specified value with the two keys
 void removeValue(V value)
          removes the given values and its keys from the map
 void removeValuesByPrimaryKey(K1 key)
          Removes all the values associated to the primary key
 void removeValuesBySecondaryKey(K2 key)
          Removes all the values associated to the secondary key
 java.util.Set<K2> secondaryKeySet()
          Returns a set view of the secondary keys contained in this map
 java.util.Collection<V> values()
          Returns a collection view of the values contained in this map
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiKeysMap

public MultiKeysMap()
Method Detail

iterator

public java.util.Iterator<V> iterator()

Specified by:
iterator in interface java.lang.Iterable<V>

put

public void put(K1 key1,
                K2 key2,
                V value)
Associates the specified value with the two keys

Parameters:
key1 - the value's primary key
key2 - the value's secondary key
value - the value

removeValue

public void removeValue(V value)
removes the given values and its keys from the map

Parameters:
value -

removeValuesByPrimaryKey

public void removeValuesByPrimaryKey(K1 key)
Removes all the values associated to the primary key

Parameters:
key - the key of type K1

removeValuesBySecondaryKey

public void removeValuesBySecondaryKey(K2 key)
Removes all the values associated to the secondary key

Parameters:
key - the key of type K2

getValuesByPrimaryKey

public java.util.Set<V> getValuesByPrimaryKey(K1 key)
Returns the values to which this map maps the specified primary key

Parameters:
key - key whose associated values are to be returned
Returns:
the values to which this map maps the specified primary key

getValuesBySecondaryKey

public java.util.Set<V> getValuesBySecondaryKey(K2 key)
Returns the values to which this map maps the specified primary key

Parameters:
key - key whose associated values are to be returned
Returns:
@return the values to which this map maps the specified secondary key

primaryKeySet

public java.util.Set<K1> primaryKeySet()
Returns a set view of the primary keys contained in this map

Returns:
a set view of the primary keys contained in this map

secondaryKeySet

public java.util.Set<K2> secondaryKeySet()
Returns a set view of the secondary keys contained in this map

Returns:
a set view of the secondary keys contained in this map

values

public java.util.Collection<V> values()
Returns a collection view of the values contained in this map

Returns:
a collection view of the values contained in this map

clean

public void clean()
Removes all mapping from this maps