structure
Class ComparableAssociation

java.lang.Object
  extended by structure.Association
      extended by structure.ComparableAssociation
All Implemented Interfaces:
java.lang.Comparable, java.util.Map.Entry

public class ComparableAssociation
extends Association
implements java.lang.Comparable

An association that can be compared.


Field Summary
 
Fields inherited from class structure.Association
theKey, theValue
 
Constructor Summary
ComparableAssociation(java.lang.Comparable key)
          Construct an association that can be ordered, from only a key.
ComparableAssociation(java.lang.Comparable key, java.lang.Object value)
          Construct a key-value association that can be ordered.
 
Method Summary
 int compareTo(java.lang.Object other)
          Determine the order of two comparable associations, based on key.
 java.lang.String toString()
          Construct a string representation of the ComparableAssociation.
 
Methods inherited from class structure.Association
equals, getKey, getValue, hashCode, setValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ComparableAssociation

public ComparableAssociation(java.lang.Comparable key)
Construct an association that can be ordered, from only a key. The value is set to null.

Parameters:
key - The (comparable) key.
Precondition:
key is non-null
Postcondition:
constructs comparable association with null value

ComparableAssociation

public ComparableAssociation(java.lang.Comparable key,
                             java.lang.Object value)
Construct a key-value association that can be ordered.

Parameters:
key - The (comparable) key.
value - The (possibly comparable) associated value.
Precondition:
key is non-null
Postcondition:
constructs association between a comparable key and a value
Method Detail

compareTo

public int compareTo(java.lang.Object other)
Determine the order of two comparable associations, based on key.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
other - The other comparable association.
Returns:
Value less-than equal to or greater than zero based on comparison
Precondition:
other is non-null ComparableAssociation
Postcondition:
returns integer representing relation between values

toString

public java.lang.String toString()
Construct a string representation of the ComparableAssociation.

Overrides:
toString in class Association
Returns:
The string representing the ComparableAssociation.
Postcondition:
returns string representation