Package com.android.utils
Class Pair<S,T>
- java.lang.Object
-
- com.android.utils.Pair<S,T>
-
- Type Parameters:
S
- The type of the first valueT
- The type of the second value
public class Pair<S,T> extends java.lang.Object
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 theof(S, T)
factory method.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
S
getFirst()
Return the first item in the pairT
getSecond()
Return the second item in the pairint
hashCode()
static <S,T>
Pair<S,T>of(S first, T second)
Constructs a new pair of the given two objects, inferring generic types.java.lang.String
toString()
-
-
-
Method Detail
-
getFirst
public S getFirst()
Return the first item in the pair- Returns:
- the first item in the pair
-
getSecond
public T getSecond()
Return the second item in the pair- Returns:
- the second item in the pair
-
of
public static <S,T> Pair<S,T> of(S first, T second)
Constructs a new pair of the given two objects, inferring generic types.- Type Parameters:
S
- the type of the first itemT
- the type of the second item- Parameters:
first
- the first item to store in the pairsecond
- the second item to store in the pair- Returns:
- a new pair wrapping the two items
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
-