com.aliasi.util
Class Pair<A,B>

java.lang.Object
  extended by com.aliasi.util.Pair<A,B>
Type Parameters:
A - the type of the first object in the pair
B - the type of the second object in the pair

public class Pair<A,B>
extends Object

The Pair class represents an immutable pair of objects of heterogeneous type. This class is useful as a return type for functions computing more than one object.

Identity conditions are that the elements are the same.

Since:
LingPipe3.5
Version:
3.8.3
Author:
Bob Carpenter

Constructor Summary
Pair(A a, B b)
          Construct a pair consisting of the two specified elements.
 
Method Summary
 A a()
          Return the first value of the pair.
 B b()
          Return the second value of the pair.
 boolean equals(Object that)
          Returns true if the specified object is a pair that has objects equal to this pair's.
 int hashCode()
          Returns the hash code of the pair.
 String toString()
          Returns a string representation of this pair, including the results of converting each of its components to a string.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Pair

public Pair(A a,
            B b)
Construct a pair consisting of the two specified elements.

Parameters:
a - First element of the pair.
b - Second element of the pair.
Method Detail

a

public A a()
Return the first value of the pair.

Returns:
The first value of the pair.

b

public B b()
Return the second value of the pair.

Returns:
The second value of the pair.

toString

public String toString()
Returns a string representation of this pair, including the results of converting each of its components to a string.

Overrides:
toString in class Object
Returns:
A string representation for this pair.

equals

public boolean equals(Object that)
Returns true if the specified object is a pair that has objects equal to this pair's.

Warning: The generic type specifications of the objects being compared do not need to match as long as the elements match.

Overrides:
equals in class Object
Parameters:
that - Object to compare to this pair.
Returns:
true if the specified object is a pair that has objects equal to this pair's.

hashCode

public int hashCode()
Returns the hash code of the pair. The hash code is defined to be consistent with equality:
 hashCode() = 31 * a().hashCode() + b().hashCode();

Overrides:
hashCode in class Object