com.taco.data
Class WrappedKeyValueMap

java.lang.Object
  extended by java.util.AbstractMap
      extended by com.taco.data.AbstractNoReturnMap
          extended by com.taco.data.WrappedKeyValueMap
All Implemented Interfaces:
INoReturnMap, java.io.Serializable, java.lang.Cloneable, java.util.Map
Direct Known Subclasses:
WrappedObservableMap

public class WrappedKeyValueMap
extends AbstractNoReturnMap
implements java.lang.Cloneable, java.io.Serializable

An implementation of Map that automatically wraps and unwraps both keys and values.

See Also:
Serialized Form

Nested Class Summary
protected  class WrappedKeyValueMap.WrappedEntry
          Represents a map entry in the entry set.
protected  class WrappedKeyValueMap.WrappedEntryIterator
          An iterator over the entry set.
protected  class WrappedKeyValueMap.WrappedEntrySet
          A class that acts as the entry set of a WrappedKeyValueMap.
 
Nested classes/interfaces inherited from class com.taco.data.AbstractNoReturnMap
AbstractNoReturnMap.NoReturnEntry, AbstractNoReturnMap.NoReturnEntrySet, AbstractNoReturnMap.NoReturnIterator
 
Nested classes/interfaces inherited from interface com.taco.data.INoReturnMap
INoReturnMap.INoReturnEntry
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry
 
Field Summary
protected  java.util.Set _cachedEntrySet
          The entry set, lazily computed, and cached.
protected  java.util.Map _innerMap
          The map that stores wrapped keys and values.
protected  IObjectMapper _keyUnwrapper
          The key unwrapper.
protected  IObjectMapper _keyWrapper
          The key wrapper.
protected  INoReturnMap _noReturnMap
          If _innerMap is an instance of INoReturnMap, this is a casted copy of _innerMap.
protected  IObjectMapper _valueUnwrapper
          The value unwrapper.
protected  IObjectMapper _valueWrapper
          The value wrapper.
 
Fields inherited from class com.taco.data.AbstractNoReturnMap
_cachedNoReturnEntrySet
 
Constructor Summary
WrappedKeyValueMap(java.util.Map map, IObjectMapper keyWrapper, IObjectMapper keyUnwrapper, IObjectMapper valueWrapper, IObjectMapper valueUnwrapper)
          Create a new instance that uses the argument map to store wrapped keys and values.
 
Method Summary
 void clear()
           
 java.lang.Object clone()
           
 java.util.Set entrySet()
           
 java.util.Set entrySetNoReturn()
          Wrap the return value of entrySet() to make it an instance of NoReturnEntrySet, which contains instances of INoReturnEntry.
 java.lang.Object get(java.lang.Object key)
           
 boolean isEmpty()
           
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
           
 void putNoReturn(java.lang.Object key, java.lang.Object value)
          This implementation simply calls put() -- there is no speed advantage to using this method.
 java.lang.Object remove(java.lang.Object key)
           
 void removeNoReturn(java.lang.Object key)
          This implementation simply calls remove() -- there is no speed advantage to using this method.
 int size()
           
 
Methods inherited from class com.taco.data.AbstractNoReturnMap
putAll
 
Methods inherited from class java.util.AbstractMap
containsKey, containsValue, equals, hashCode, keySet, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
containsKey, containsValue, equals, hashCode, keySet, values
 

Field Detail

_innerMap

protected java.util.Map _innerMap
The map that stores wrapped keys and values.


_keyWrapper

protected IObjectMapper _keyWrapper
The key wrapper.


_keyUnwrapper

protected IObjectMapper _keyUnwrapper
The key unwrapper.


_valueWrapper

protected IObjectMapper _valueWrapper
The value wrapper.


_valueUnwrapper

protected IObjectMapper _valueUnwrapper
The value unwrapper.


_noReturnMap

protected INoReturnMap _noReturnMap
If _innerMap is an instance of INoReturnMap, this is a casted copy of _innerMap.


_cachedEntrySet

protected transient java.util.Set _cachedEntrySet
The entry set, lazily computed, and cached. The entry set by itself has no state, even though each iterator it returns does.

Constructor Detail

WrappedKeyValueMap

public WrappedKeyValueMap(java.util.Map map,
                          IObjectMapper keyWrapper,
                          IObjectMapper keyUnwrapper,
                          IObjectMapper valueWrapper,
                          IObjectMapper valueUnwrapper)
Create a new instance that uses the argument map to store wrapped keys and values.

Parameters:
map - The map used to store wrapped keys and values.
keyWrapper - Used to wrap keys. If null, keys will not be wrapped.
keyUnwrapper - Used to unwrap keys. If null, keys will not be unwrapped.
valueWrapper - Used to wrap values. If null, values will not be wrapped.
valueUnwrapper - Used to unwrap values. If null, values will not be unwrapped.
Throws:
java.lang.NullPointerException - if map is null.
Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.util.AbstractMap
Throws:
java.lang.CloneNotSupportedException

get

public java.lang.Object get(java.lang.Object key)
Specified by:
get in interface java.util.Map
Overrides:
get in class java.util.AbstractMap

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Specified by:
put in interface java.util.Map
Overrides:
put in class java.util.AbstractMap

putNoReturn

public void putNoReturn(java.lang.Object key,
                        java.lang.Object value)
Description copied from class: AbstractNoReturnMap
This implementation simply calls put() -- there is no speed advantage to using this method.

Specified by:
putNoReturn in interface INoReturnMap
Overrides:
putNoReturn in class AbstractNoReturnMap

remove

public java.lang.Object remove(java.lang.Object key)
Specified by:
remove in interface java.util.Map
Overrides:
remove in class java.util.AbstractMap

removeNoReturn

public void removeNoReturn(java.lang.Object key)
Description copied from class: AbstractNoReturnMap
This implementation simply calls remove() -- there is no speed advantage to using this method.

Specified by:
removeNoReturn in interface INoReturnMap
Overrides:
removeNoReturn in class AbstractNoReturnMap

entrySet

public java.util.Set entrySet()
Specified by:
entrySet in interface java.util.Map
Specified by:
entrySet in class java.util.AbstractMap

entrySetNoReturn

public java.util.Set entrySetNoReturn()
Description copied from class: AbstractNoReturnMap
Wrap the return value of entrySet() to make it an instance of NoReturnEntrySet, which contains instances of INoReturnEntry.

Specified by:
entrySetNoReturn in interface INoReturnMap
Overrides:
entrySetNoReturn in class AbstractNoReturnMap

size

public int size()
Specified by:
size in interface java.util.Map
Overrides:
size in class java.util.AbstractMap

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Map
Overrides:
isEmpty in class java.util.AbstractMap

clear

public void clear()
Specified by:
clear in interface java.util.Map
Overrides:
clear in class java.util.AbstractMap