|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectAbstractMap<K,V>
DerivedMap<BK,K,V>
BK
- The type of keys in the backing map.K
- The type of keys in this map.V
- The type of values in both this map and the underlying map.public abstract class DerivedMap<BK,K,V>
A map whose keys are derived from an other map. The keys are derived only when
requested, which make it possible to backup potentially large maps. Implementations
need only to overrides baseToDerived(BK)
and derivedToBase(K)
methods.
This set do not supports null
key, since null
is used
when no mapping from base to this
exists.
This class is serializable if the underlying base set is serializable
too.
This class is not thread-safe. Synchronizations (if wanted) are user's reponsability.
modules/library/metadata (gt-metadata.jar)
Field Summary | |
---|---|
protected Map<BK,V> |
base
The base map whose keys are derived from. |
Constructor Summary | |
---|---|
DerivedMap(Map<BK,V> base)
Deprecated. Use #DerivedMap(Map, Class instead. |
|
DerivedMap(Map<BK,V> base,
Class<K> keyType)
Creates a new derived map from the specified base map. |
Method Summary | |
---|---|
protected abstract K |
baseToDerived(BK key)
Transforms a key from the base map to a key in this map. |
boolean |
containsKey(Object key)
Returns true if this map contains a mapping for the specified key. |
boolean |
containsValue(Object value)
Returns true if this map maps one or more keys to this value. |
protected abstract BK |
derivedToBase(K key)
Transforms a key from this derived map to a key in the base map. |
Set<Map.Entry<K,V>> |
entrySet()
Returns a set view of the mappings contained in this map. |
V |
get(Object key)
Returns the value to which this map maps the specified key. |
boolean |
isEmpty()
Returns true if this map contains no key-value mappings. |
Set<K> |
keySet()
Returns a set view of the keys contained in this map. |
V |
put(K key,
V value)
Associates the specified value with the specified key in this map. |
V |
remove(Object key)
Removes the mapping for this key from this map if present. |
int |
size()
Returns the number of key-value mappings in this map. |
Collection<V> |
values()
Returns a collection view of the values contained in this map. |
Methods inherited from class AbstractMap |
---|
clear, clone, equals, hashCode, putAll, toString |
Methods inherited from class Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final Map<BK,V> base
baseToDerived(BK)
,
derivedToBase(K)
Constructor Detail |
---|
public DerivedMap(Map<BK,V> base)
#DerivedMap(Map, Class
instead.
base
- The base map.public DerivedMap(Map<BK,V> base, Class<K> keyType)
base
- The base map.keyType
- the type of keys in the derived map.Method Detail |
---|
protected abstract K baseToDerived(BK key)
null
.
key
- A ley from the base map.
key
,
or null
.protected abstract BK derivedToBase(K key)
key
- A key in this map.
public int size()
size
in interface Map<K,V>
size
in class AbstractMap<K,V>
public boolean isEmpty()
true
if this map contains no key-value mappings.
isEmpty
in interface Map<K,V>
isEmpty
in class AbstractMap<K,V>
true
if this map contains no key-value mappings.public boolean containsValue(Object value)
true
if this map maps one or more keys to this value.
The default implementation invokes
base.containsValue(value)
.
containsValue
in interface Map<K,V>
containsValue
in class AbstractMap<K,V>
true
if this map maps one or more keys to this value.public boolean containsKey(Object key)
true
if this map contains a mapping for the specified key.
The default implementation invokes
base.containsKey(derivedToBase(key))
.
containsKey
in interface Map<K,V>
containsKey
in class AbstractMap<K,V>
key
- key whose presence in this map is to be tested.
true
if this map contains a mapping for the specified key.public V get(Object key)
base.get(derivedToBase(key))
.
get
in interface Map<K,V>
get
in class AbstractMap<K,V>
key
- key whose associated value is to be returned.
public V put(K key, V value) throws UnsupportedOperationException
base.put(derivedToBase(key), value)
.
put
in interface Map<K,V>
put
in class AbstractMap<K,V>
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.
null
if there was no mapping for key.
UnsupportedOperationException
- if the base map doesn't
supports the put
operation.public V remove(Object key) throws UnsupportedOperationException
base.remove(derivedToBase(key))
.
remove
in interface Map<K,V>
remove
in class AbstractMap<K,V>
key
- key whose mapping is to be removed from the map.
null
if there was no entry for key.
UnsupportedOperationException
- if the base map doesn't
supports the remove
operation.public Set<K> keySet()
keySet
in interface Map<K,V>
keySet
in class AbstractMap<K,V>
public Collection<V> values()
values
in interface Map<K,V>
values
in class AbstractMap<K,V>
public Set<Map.Entry<K,V>> entrySet()
entrySet
in interface Map<K,V>
entrySet
in class AbstractMap<K,V>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |