com.google.gdata.util.common.base
Class Pair<A,B>

java.lang.Object
  extended by com.google.gdata.util.common.base.Pair<A,B>
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class Pair<A,B>
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

Pair is an expedient way to combine two arbitrary objects into one. Its use is not to be preferred to creating a custom type, but it can be handy in a pinch. If your equals(java.lang.Object), hashCode(), toString(), and/or clone() behavior matter to you at all, you may not want to use this (or you may at least wish to subclass).

This class may be used with the Google Web Toolkit (GWT).

See Also:
Serialized Form

Field Summary
 A first
          The first element of the pair.
 B second
          The second element of the pair.
 
Constructor Summary
Pair(A first, B second)
          Cumbersome way to create a new pair (see of(A, B).
 
Method Summary
 Pair<A,B> clone()
           
 boolean equals(java.lang.Object object)
           
 A getFirst()
          Optional accessor method for first.
 B getSecond()
          Optional accessor method for second.
 int hashCode()
           
static
<A,B> Pair<A,B>
of(A first, B second)
          Creates a new pair containing the given objects in order.
 java.lang.String toString()
          This implementation returns the String representation of this pair in the form (string1, string2), where string1 and string2 are the Object.toString() representations of the elements inside the pair.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

first

public final A first
The first element of the pair.


second

public final B second
The second element of the pair.

Constructor Detail

Pair

public Pair(A first,
            B second)
Cumbersome way to create a new pair (see of(A, B).

Method Detail

of

public static <A,B> Pair<A,B> of(A first,
                                 B second)
Creates a new pair containing the given objects in order.


getFirst

public A getFirst()
Optional accessor method for first.


getSecond

public B getSecond()
Optional accessor method for second.


clone

public Pair<A,B> clone()
Overrides:
clone in class java.lang.Object

equals

public boolean equals(java.lang.Object object)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
This implementation returns the String representation of this pair in the form (string1, string2), where string1 and string2 are the Object.toString() representations of the elements inside the pair.

Overrides:
toString in class java.lang.Object