Orbital library

orbital.util
Class KeyValuePair

java.lang.Object
  extended by orbital.util.KeyValuePair
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable

public class KeyValuePair
extends java.lang.Object
implements java.lang.Comparable, java.io.Serializable

This class is a KeyValuePair that contains a pair ⟨key,value⟩ each of which are objects. An instance of KeyValuePair is mainly identified by its key value.

For equality and similar methods, only the key is considered.

Author:
André Platzer
See Also:
Pair, Map.Entry, Serialized Form

Field Summary
protected  java.lang.Object key
          The key for this pair.
protected  java.lang.Object value
          The value of this pair.
 
Constructor Summary
KeyValuePair()
           
KeyValuePair(java.lang.Object key, java.lang.Object value)
          Create a new pair ⟨key, value⟩.
 
Method Summary
 int compareTo(java.lang.Object o)
          Compare two KeyValuePair objects according to their keys.
 boolean equals(java.lang.Object o)
          Checks two KeyValuePair objects for equal keys.
 java.lang.Object getKey()
          Get/Set-Methods.
 java.lang.Object getValue()
           
 int hashCode()
           
 void setKey(java.lang.Object key)
           
 void setValue(java.lang.Object value)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

key

protected java.lang.Object key
The key for this pair.


value

protected java.lang.Object value
The value of this pair.

Constructor Detail

KeyValuePair

public KeyValuePair()

KeyValuePair

public KeyValuePair(java.lang.Object key,
                    java.lang.Object value)
Create a new pair ⟨key, value⟩.

Method Detail

getKey

public java.lang.Object getKey()
Get/Set-Methods.


setKey

public void setKey(java.lang.Object key)

getValue

public java.lang.Object getValue()

setValue

public void setValue(java.lang.Object value)

compareTo

public int compareTo(java.lang.Object o)
              throws java.lang.ClassCastException
Compare two KeyValuePair objects according to their keys. This will only work for Comparable keys and throw an exception otherwise.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - the (KeyValuePair) object to be compared to.
Returns:
key.compareTo(o), when key implements Comparable.
Throws:
java.lang.ClassCastException - when neither of the keys in the KeyValuePair objects compared implements Comparable, or o is not even a KeyValuePair.

equals

public boolean equals(java.lang.Object o)
Checks two KeyValuePair objects for equal keys.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

Orbital library
1.3.0: 11 Apr 2009

Copyright © 1996-2009 André Platzer
All Rights Reserved.