common-util

local.tomas.util.collections
Class MappedMap<K,J,F,T>

java.lang.Object
  extended by local.tomas.util.collections.MappedMap<K,J,F,T>
Type Parameters:
K - mapped map key type
J - base map key type
F - base map value type
T - mapped map value type
All Implemented Interfaces:
Map<K,T>
Direct Known Subclasses:
SimpleMappedMap

public class MappedMap<K,J,F,T>
extends Object
implements Map<K,T>

Mapped map. The mapped map maps the values of a base map to the values of a target map using two mappings passed to the constructor. The resulting map is defined as follows:

 mapped_map[key] := value_mapping(base_map[key_mapping(key)])
 

Author:
tomas.teubner

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
protected  ObjectMapping<J> keyMapping
           
protected  Map<J,F> map
           
protected  ObjectMapping<T> valueMapping
           
 
Constructor Summary
MappedMap(Map<J,F> map, ObjectMapping<J> keyMapping, ObjectMapping<T> valueMapping)
          Construct mapped map.
 
Method Summary
 void clear()
           
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
 Set<Map.Entry<K,T>> entrySet()
           
 T get(Object key)
           
 boolean isEmpty()
           
 Set<K> keySet()
           
 T put(K key, T value)
           
 void putAll(Map<? extends K,? extends T> t)
           
 T remove(Object key)
           
 int size()
           
 Collection<T> values()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

map

protected Map<J,F> map

keyMapping

protected ObjectMapping<J> keyMapping

valueMapping

protected ObjectMapping<T> valueMapping
Constructor Detail

MappedMap

public MappedMap(Map<J,F> map,
                 ObjectMapping<J> keyMapping,
                 ObjectMapping<T> valueMapping)
Construct mapped map.

Parameters:
map - base map
keyMapping - maps target keys to base keys
valueMapping - maps base values to target values
Method Detail

size

public int size()
Specified by:
size in interface Map<K,T>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Map<K,T>

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map<K,T>

containsValue

public boolean containsValue(Object value)
Specified by:
containsValue in interface Map<K,T>

get

public T get(Object key)
Specified by:
get in interface Map<K,T>

put

public T put(K key,
             T value)
Specified by:
put in interface Map<K,T>
Throws:
UnsupportedOperationException - when invoked

remove

public T remove(Object key)
Specified by:
remove in interface Map<K,T>

putAll

public void putAll(Map<? extends K,? extends T> t)
Specified by:
putAll in interface Map<K,T>
Throws:
UnsupportedOperationException - when invoked

clear

public void clear()
Specified by:
clear in interface Map<K,T>

keySet

public Set<K> keySet()
Specified by:
keySet in interface Map<K,T>
Throws:
UnsupportedOperationException - when invoked

values

public Collection<T> values()
Specified by:
values in interface Map<K,T>

entrySet

public Set<Map.Entry<K,T>> entrySet()
Specified by:
entrySet in interface Map<K,T>
Throws:
UnsupportedOperationException - when invoked

common-util

Copyright © 2005-2007 Tomas Teubner. All Rights Reserved.