Opus5
Class Association

java.lang.Object
  |
  +--Opus5.AbstractObject
        |
        +--Opus5.Association
All Implemented Interfaces:
Comparable

public class Association
extends AbstractObject

An association is a (key, value) pair that implements the Comparable interface.

Version:
$Id: Association.java,v 3.1 1998/07/28 01:32:17 brpreiss Exp $
Author:
Bruno R. Preiss, P.Eng.
See Also:
Comparable

Field Summary
protected  Comparable key
          The key.
protected  java.lang.Object value
          The value.
 
Fields inherited from interface Opus5.Comparable
copyright
 
Constructor Summary
Association(Comparable key)
          Constructs an Association with the specified key.
Association(Comparable key, java.lang.Object value)
          Constructs an Association with the specified key and value.
 
Method Summary
protected  int compareTo(Comparable object)
          Compares this association with the specified comparable object.
 Comparable getKey()
          Returns the key of this association.
 java.lang.Object getValue()
          Returns the value of this association.
 int hashCode()
          Returns a hashcode for this association.
 java.lang.String toString()
          Returns a string representation of this association.
 
Methods inherited from class Opus5.AbstractObject
compare, equals, isEQ, isGE, isGT, isLE, isLT, isNE
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

key

protected Comparable key
The key.

value

protected java.lang.Object value
The value.
Constructor Detail

Association

public Association(Comparable key,
                   java.lang.Object value)
Constructs an Association with the specified key and value.
Parameters:
key - The desired key.
value - The desired value.

Association

public Association(Comparable key)
Constructs an Association with the specified key.
Parameters:
key - The desired key.
Method Detail

getKey

public Comparable getKey()
Returns the key of this association.
Returns:
The key of this association.

getValue

public java.lang.Object getValue()
Returns the value of this association.
Returns:
The value of this association.

compareTo

protected int compareTo(Comparable object)
Compares this association with the specified comparable object. The specified comparable object is assumed to be an Association instance. The two associations are compared by comparing just their keys.
Overrides:
compareTo in class AbstractObject
Parameters:
object - The object with which this object is compared.
Returns:
A number less than zero if the key of this association is less than the key of the specified one; a number greater than zero if the key of this association is greater than the key of the specified one; zero if the keys of both associations are equal.

toString

public java.lang.String toString()
Returns a string representation of this association.
Overrides:
toString in class java.lang.Object
Returns:
a string representation of this association.

hashCode

public int hashCode()
Returns a hashcode for this association. The hashcode of an this association is just the hashcode of the key.
Overrides:
hashCode in class java.lang.Object
Returns:
A hashcode for this association.