com.groiss.ds
Class Pair

java.lang.Object
  extended by com.groiss.ds.Pair
All Implemented Interfaces:
KeyValuePair, java.io.Serializable
Direct Known Subclasses:
ComparablePair

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

A Pair is an object that contains two other objects. It is most commonly used for conveniently storing and passing pairs of objects.

See Also:
Serialized Form

Field Summary
 java.lang.Object first
          The first object.
 java.lang.Object second
          The second object.
 
Constructor Summary
Pair()
           
Pair(java.lang.Object first, java.lang.Object second)
          Constructor for holding a pair of objects.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Returns true if obj is also a Pair and contains two objects equal to the two objects of this Pair.
 java.lang.Object getKey()
          Return the first object
 java.lang.Object getValue()
          Return the second object
 int hashCode()
          Builds a new hash code out of the two objects' hash codes.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

first

public java.lang.Object first
The first object.


second

public java.lang.Object second
The second object.

Constructor Detail

Pair

public Pair()

Pair

public Pair(java.lang.Object first,
            java.lang.Object second)
Constructor for holding a pair of objects.

Method Detail

getKey

public java.lang.Object getKey()
Return the first object

Specified by:
getKey in interface KeyValuePair

getValue

public java.lang.Object getValue()
Return the second object

Specified by:
getValue in interface KeyValuePair

toString

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

equals

public boolean equals(java.lang.Object obj)
Returns true if obj is also a Pair and contains two objects equal to the two objects of this Pair. null references are considered as equal, too.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Builds a new hash code out of the two objects' hash codes.

Overrides:
hashCode in class java.lang.Object


Copyright © 2001-2006 Groiss Informatics GmbH. All Rights Reserved.