org.opentox.toxotis.client
Class Pair<K extends Serializable,V extends Serializable>

java.lang.Object
  extended by org.opentox.toxotis.client.Pair<K,V>
All Implemented Interfaces:
Serializable, Map.Entry<K,V>

public class Pair<K extends Serializable,V extends Serializable>
extends Object
implements Map.Entry<K,V>, Serializable

A Pair is a simple implementation of the interface Map.Entry.

Author:
Pantelis Sopasakis, Charalampos Chomenides
See Also:
Serialized Form

Constructor Summary
protected Pair()
          Dummy constructor which is protected to allow for subclassing of this class.
  Pair(K key, V value)
          Construct a new pair with a key and a value.
 
Method Summary
 K getKey()
          Returns the key corresponding to this entry.
 V getValue()
          Returns the value corresponding to this entry.
 V setValue(V value)
          Replaces the value corresponding to this entry with the specified value (optional operation).
 
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.Entry
equals, hashCode
 

Constructor Detail

Pair

public Pair(K key,
            V value)
Construct a new pair with a key and a value. When a pair is an element of a map, then keys uniquely identify every element therein.

Parameters:
key - Key of the pair (first argument)
value - Value of the pair (second argument)

Pair

protected Pair()
Dummy constructor which is protected to allow for subclassing of this class.

Method Detail

getKey

public K getKey()
Returns the key corresponding to this entry.

Specified by:
getKey in interface Map.Entry<K extends Serializable,V extends Serializable>
Returns:
the key corresponding to this entry
Throws:
IllegalStateException - implementations may, but are not required to, throw this exception if the entry has been removed from the backing map.

getValue

public V getValue()
Returns the value corresponding to this entry. If the mapping has been removed from the backing map (by the iterator's remove operation), the results of this call are undefined.

Specified by:
getValue in interface Map.Entry<K extends Serializable,V extends Serializable>
Returns:
the value corresponding to this entry
Throws:
IllegalStateException - implementations may, but are not required to, throw this exception if the entry has been removed from the backing map.

setValue

public V setValue(V value)
Replaces the value corresponding to this entry with the specified value (optional operation). (Writes through to the map.) The behavior of this call is undefined if the mapping has already been removed from the map (by the iterator's remove operation).

Specified by:
setValue in interface Map.Entry<K extends Serializable,V extends Serializable>
Parameters:
value - new value to be stored in this entry
Returns:
old value corresponding to the entry
Throws:
UnsupportedOperationException - if the put operation is not supported by the backing map
ClassCastException - if the class of the specified value prevents it from being stored in the backing map
NullPointerException - if the backing map does not permit null values, and the specified value is null
IllegalArgumentException - if some property of this value prevents it from being stored in the backing map
IllegalStateException - implementations may, but are not required to, throw this exception if the entry has been removed from the backing map.


Copyright © 2011-2012 OpenTox. All Rights Reserved.