Pair

public final class Pair
extends Object

java.lang.Object
   ↳ com.android.utils.Pair<S, T>


A Pair class is simply a 2-tuple for use in this package. We might want to think about adding something like this to a more central utility place, or replace it by a common tuple class if one exists, or even rewrite the layout classes using this Pair by a more dedicated data structure (so we don't have to pass around generic signatures as is currently done, though at least the construction is helped a bit by the of(S, T) factory method.

Summary

Public methods

boolean equals(Object obj)
S getFirst()

Return the first item in the pair

T getSecond()

Return the second item in the pair

int hashCode()
static <S, T> Pair<S, T> of(S first, T second)

Constructs a new pair of the given two objects, inferring generic types.

String toString()

Public methods

equals

public boolean equals (Object obj)

Parameters
obj Object

Returns
boolean

getFirst

public S getFirst ()

Return the first item in the pair

Returns
S the first item in the pair

getSecond

public T getSecond ()

Return the second item in the pair

Returns
T the second item in the pair

hashCode

public int hashCode ()

Returns
int

of

public static Pair<S, T> of (S first, 
                T second)

Constructs a new pair of the given two objects, inferring generic types.

Parameters
first S: the first item to store in the pair

second T: the second item to store in the pair

Returns
Pair<S, T> a new pair wrapping the two items

toString

public String toString ()

Returns
String