net.sf.japaki.beans
Class MapItemBean<K,V>

java.lang.Object
  extended by net.sf.japaki.beans.MapItemBean<K,V>
All Implemented Interfaces:
Map.Entry<K,V>, KeyValueBean<K,V>, SinglePropertyBean<V>

public final class MapItemBean<K,V>
extends Object
implements SinglePropertyBean<V>, KeyValueBean<K,V>

A bean with a single property that is stored in an underlying map at a fixed key.


Constructor Summary
MapItemBean(Map<K,V> map, K key)
          Constructs a new MapItemBean.
 
Method Summary
 boolean equals(Object obj)
           
 K getKey()
           
 V getValue()
          Retrieves the value at the predefined key from the underlying map.
 int hashCode()
           
 K setKey(K key)
          Does nothing.
 V setValue(V value)
          Stores the value at the predefined key in the underlying map.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MapItemBean

public MapItemBean(Map<K,V> map,
                   K key)
Constructs a new MapItemBean.

Parameters:
map - map where the property's value is stored and retrieved from.
key - position of the property in the map
Throws:
ClassCastException - if the key is of an inappropriate type for the map
NullPointerException - if map is null or if the key is null and the map does not permit null keys
Method Detail

setKey

public K setKey(K key)
Does nothing.

Specified by:
setKey in interface KeyValueBean<K,V>
Parameters:
key - new key to be stored in this bean
Throws:
IllegalArgumentException - if the specified key is not equal to the old key.

getKey

public K getKey()
Specified by:
getKey in interface Map.Entry<K,V>

getValue

public V getValue()
Retrieves the value at the predefined key from the underlying map.

Specified by:
getValue in interface Map.Entry<K,V>
Specified by:
getValue in interface SinglePropertyBean<V>
Returns:
the found value.

setValue

public V setValue(V value)
Stores the value at the predefined key in the underlying map.

Specified by:
setValue in interface Map.Entry<K,V>
Specified by:
setValue in interface SinglePropertyBean<V>
Parameters:
value - value to be stored.
Returns:
the previous value associated with the underlying key, or null if there was no mapping for the key
Throws:
UnsupportedOperationException - depending on the underlying map
ClassCastException - depending on the underlying map
NullPointerException - depending on the underlying map
IllegalArgumentException - depending on the underlying map

hashCode

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

equals

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

toString

public String toString()
Overrides:
toString in class Object