be.SIRAPRISE.util
Class IntersectableMap<K,V>

java.lang.Object
  extended by be.SIRAPRISE.util.IntersectableMap<K,V>
Type Parameters:
K -
V -
All Implemented Interfaces:
java.util.Map<K,V>
Direct Known Subclasses:
IntersectableHashMap, IntersectableLinkedHashMap, IntersectableTreeMap

public abstract class IntersectableMap<K,V>
extends java.lang.Object
implements java.util.Map<K,V>

Defines the intersect, minus and union operations on maps

Author:
Erwin Smout

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
IntersectableMap()
           
 
Method Summary
 void clear()
           
 java.lang.Object clone()
           
 boolean containsKey(java.lang.Object key)
           
 boolean containsValue(java.lang.Object value)
           
 java.util.Set<java.util.Map.Entry<K,V>> entrySet()
           
 boolean equals(java.lang.Object obj)
           
 V get(java.lang.Object key)
           
 int hashCode()
           
 IntersectableMap<K,V> intersect(java.util.Set<?> keys)
          Returns a Map that holds only the entries whose keys also occur in keys, and whose class is the same as the caller's class.
 java.util.Map<K,V> intersect(java.util.Set<?> keys, java.lang.Class<? extends java.util.Map<K,V>> resultClass)
          Returns a Map that holds only the entries whose keys also occur in keys
 boolean isEmpty()
           
 java.util.Set<K> keySet()
           
 IntersectableMap<K,V> minus(java.util.Set<?> keys)
          Returns a Map that holds only the entries whose keys do not occur in set, and whose class is the same as the caller's class.
 java.util.Map<K,V> minus(java.util.Set<?> keys, java.lang.Class<? extends java.util.Map<K,V>> resultClass)
          Returns a Map that holds only the entries whose keys do not occur in keys
 V put(K key, V value)
           
 void putAll(java.util.Map<? extends K,? extends V> t)
           
 V remove(java.lang.Object key)
           
 int size()
           
 java.lang.String toString()
           
 IntersectableMap<K,V> union(java.util.Map<K,V> otherMap)
          Returns a Map that holds only the entries whose keys do not occur in set, and whose class is the same as the caller's class.
 java.util.Map<K,V> union(java.util.Map<K,V> otherMap, java.lang.Class<java.util.Map<K,V>> resultClass)
          Returns a Map that holds the entries that occur in either this or the other map.
 java.util.Collection<V> values()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IntersectableMap

public IntersectableMap()
Method Detail

clear

public final void clear()
Specified by:
clear in interface java.util.Map<K,V>

clone

public final java.lang.Object clone()
Overrides:
clone in class java.lang.Object

containsKey

public final boolean containsKey(java.lang.Object key)
Specified by:
containsKey in interface java.util.Map<K,V>

containsValue

public final boolean containsValue(java.lang.Object value)
Specified by:
containsValue in interface java.util.Map<K,V>

entrySet

public final java.util.Set<java.util.Map.Entry<K,V>> entrySet()
Specified by:
entrySet in interface java.util.Map<K,V>

equals

public final boolean equals(java.lang.Object obj)
Specified by:
equals in interface java.util.Map<K,V>
Overrides:
equals in class java.lang.Object

get

public final V get(java.lang.Object key)
Specified by:
get in interface java.util.Map<K,V>

hashCode

public final int hashCode()
Specified by:
hashCode in interface java.util.Map<K,V>
Overrides:
hashCode in class java.lang.Object

intersect

public final IntersectableMap<K,V> intersect(java.util.Set<?> keys)
Returns a Map that holds only the entries whose keys also occur in keys, and whose class is the same as the caller's class.

Parameters:
keys - The set that is to be intersected with the keys of this map
Returns:
A map holding this map's entries whose keys also occur in keys

intersect

public final java.util.Map<K,V> intersect(java.util.Set<?> keys,
                                          java.lang.Class<? extends java.util.Map<K,V>> resultClass)
                                   throws java.lang.InstantiationException,
                                          java.lang.IllegalAccessException
Returns a Map that holds only the entries whose keys also occur in keys

Parameters:
keys - The set that is to be intersected with the keys of this map
resultClass - the Class that the result object must be
Returns:
A map holding this map's entries whose keys also occur in keys
Throws:
java.lang.IllegalAccessException
java.lang.InstantiationException

isEmpty

public final boolean isEmpty()
Specified by:
isEmpty in interface java.util.Map<K,V>

keySet

public final java.util.Set<K> keySet()
Specified by:
keySet in interface java.util.Map<K,V>

minus

public final IntersectableMap<K,V> minus(java.util.Set<?> keys)
Returns a Map that holds only the entries whose keys do not occur in set, and whose class is the same as the caller's class.

Parameters:
keys - The set that is to be intersected with the keys of this map
Returns:
A map holding this map's entries whose keys also occur in keys

minus

public final java.util.Map<K,V> minus(java.util.Set<?> keys,
                                      java.lang.Class<? extends java.util.Map<K,V>> resultClass)
                               throws java.lang.InstantiationException,
                                      java.lang.IllegalAccessException
Returns a Map that holds only the entries whose keys do not occur in keys

Parameters:
keys - The set that is to be differentiated with the keys of this map
resultClass - the Class that the result object must be
Returns:
A map holding this map's entries whose keys do not occur in keys
Throws:
java.lang.IllegalAccessException
java.lang.InstantiationException

put

public final V put(K key,
                   V value)
Specified by:
put in interface java.util.Map<K,V>

putAll

public final void putAll(java.util.Map<? extends K,? extends V> t)
Specified by:
putAll in interface java.util.Map<K,V>

remove

public final V remove(java.lang.Object key)
Specified by:
remove in interface java.util.Map<K,V>

size

public final int size()
Specified by:
size in interface java.util.Map<K,V>

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

union

public final IntersectableMap<K,V> union(java.util.Map<K,V> otherMap)
                                  throws EqualKeyUnequalValuesException
Returns a Map that holds only the entries whose keys do not occur in set, and whose class is the same as the caller's class.

Parameters:
otherMap - the map to be unioned with this one
Returns:
A map holding this map's entries whose keys also occur in keys
Throws:
EqualKeyUnequalValuesException

union

public final java.util.Map<K,V> union(java.util.Map<K,V> otherMap,
                                      java.lang.Class<java.util.Map<K,V>> resultClass)
                               throws EqualKeyUnequalValuesException,
                                      java.lang.InstantiationException,
                                      java.lang.IllegalAccessException
Returns a Map that holds the entries that occur in either this or the other map.

Parameters:
otherMap - the map to be unioned with this one
resultClass - the Class that the result object must be
Returns:
A map holding all of this and othermap's entries
Throws:
EqualKeyUnequalValuesException
java.lang.IllegalAccessException
java.lang.InstantiationException

values

public final java.util.Collection<V> values()
Specified by:
values in interface java.util.Map<K,V>