org.apache.hadoop.hbase.util
Class Pair<T1,T2>

java.lang.Object
  extended by org.apache.hadoop.hbase.util.Pair<T1,T2>
Type Parameters:
T1 -
T2 -
All Implemented Interfaces:
Serializable

@InterfaceAudience.Public
@InterfaceStability.Stable
public class Pair<T1,T2>
extends Object
implements Serializable

A generic class for pairs.

See Also:
Serialized Form

Field Summary
protected  T1 first
           
protected  T2 second
           
 
Constructor Summary
Pair()
          Default constructor.
Pair(T1 a, T2 b)
          Constructor
 
Method Summary
 boolean equals(Object other)
           
 T1 getFirst()
          Return the first element stored in the pair.
 T2 getSecond()
          Return the second element stored in the pair.
 int hashCode()
           
static
<T1,T2> Pair<T1,T2>
newPair(T1 a, T2 b)
          Constructs a new pair, inferring the type via the passed arguments
 void setFirst(T1 a)
          Replace the first element of the pair.
 void setSecond(T2 b)
          Replace the second element of the pair.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

first

protected T1 first

second

protected T2 second
Constructor Detail

Pair

public Pair()
Default constructor.


Pair

public Pair(T1 a,
            T2 b)
Constructor

Parameters:
a - operand
b - operand
Method Detail

newPair

public static <T1,T2> Pair<T1,T2> newPair(T1 a,
                                          T2 b)
Constructs a new pair, inferring the type via the passed arguments

Type Parameters:
T1 - type for first
T2 - type for second
Parameters:
a - first element
b - second element
Returns:
a new pair containing the passed arguments

setFirst

public void setFirst(T1 a)
Replace the first element of the pair.

Parameters:
a - operand

setSecond

public void setSecond(T2 b)
Replace the second element of the pair.

Parameters:
b - operand

getFirst

public T1 getFirst()
Return the first element stored in the pair.

Returns:
T1

getSecond

public T2 getSecond()
Return the second element stored in the pair.

Returns:
T2

equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.