org.deegree.commons.utils
Class Pair<T,U>

java.lang.Object
  extended by org.deegree.commons.utils.Pair<T,U>
Type Parameters:
T - the first Object of the pair
U - the second Object of the pair
Direct Known Subclasses:
ComparablePair, DoublePair, JTSGeometryPair, StringPair

public class Pair<T,U>
extends Object

Pair is a convenience class, which pairs two objects. For a pair of Strings see StringPair.

Version:
$Revision: 29934 $, $Date: 2011-03-08 15:18:56 +0100 (Tue, 08 Mar 2011) $
Author:
Rutger Bezema, last edited by: $Author: lbuesching $

Field Summary
 T first
          first value of the pair.
 U second
          second value of the pair.
 
Constructor Summary
Pair()
          Create a pair with null objects.
Pair(T first, U second)
           
 
Method Summary
 boolean equals(Object other)
           
 T getFirst()
           
 U getSecond()
           
 int hashCode()
          Implementation as proposed by Joshua Block in Effective Java (Addison-Wesley 2001), which supplies an even distribution and is relatively fast.
 boolean hasNull()
           
 boolean isNull()
           
 void setFirst(T first)
           
 void setSecond(U second)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

first

public T first
first value of the pair.


second

public U second
second value of the pair.

Constructor Detail

Pair

public Pair(T first,
            U second)
Parameters:
first - value of the pair.
second - value of the pair.

Pair

public Pair()
Create a pair with null objects.

Method Detail

equals

public boolean equals(Object other)
Overrides:
equals in class Object

hashCode

public int hashCode()
Implementation as proposed by Joshua Block in Effective Java (Addison-Wesley 2001), which supplies an even distribution and is relatively fast. It is created from field f as follows:

Combining the hash code(s) computed above: result = 37 * result + code;

Overrides:
hashCode in class Object
Returns:
(int) ( result >>> 32 ) ^ (int) result;
See Also:
Object.hashCode()

toString

public String toString()
Overrides:
toString in class Object

hasNull

public boolean hasNull()
Returns:
true if either the first or the second value is null

isNull

public boolean isNull()
Returns:
true if the first and the second value are null

getFirst

public T getFirst()

getSecond

public U getSecond()

setFirst

public void setFirst(T first)

setSecond

public void setSecond(U second)


Copyright © 2011. All Rights Reserved.