com.springsource.util.math
Class OrderedPair<F,S>

java.lang.Object
  extended by com.springsource.util.math.OrderedPair<F,S>
Type Parameters:
F - type of first element
S - type of second element

public final class OrderedPair<F,S>
extends java.lang.Object

Defines an ordered pair of elements of types F and S respectively.

The elements may be null, in which case they are without type.
For example:

        ( new OrderedPair(42,null) )
 .equals( new OrderedPair(42,null) )
returns true.

Concurrent Semantics
Implementation is immutable.
Note: the elements are final but that doesn't stop them being modified after the pair is constructed. The hashCode() of the OrderedPair may then change.

Since:
1.0
Author:
Rob Harrop, Steve Powell

Field Summary
private  F first
           
private  S second
           
 
Constructor Summary
OrderedPair(F first, S second)
          Creates a new OrderedPair.
 
Method Summary
 boolean equals(java.lang.Object obj)
          
 F getFirst()
          Gets the first member of the OrderedPair.
 S getSecond()
          Gets the second member of the OrderedPair.
 int hashCode()
          
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

first

private final F first

second

private final S second
Constructor Detail

OrderedPair

public OrderedPair(F first,
                   S second)
Creates a new OrderedPair.

Parameters:
first - the first member of the OrderedPair.
second - the second member of the OrderedPair.
Method Detail

getFirst

public F getFirst()
Gets the first member of the OrderedPair.

Returns:
the first member of the OrderedPair.

getSecond

public S getSecond()
Gets the second member of the OrderedPair.

Returns:
the second member of the OrderedPair.

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)

Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object