Add factory pattern to Pair so template types can be inferred from input

params.

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1054843 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nicolas Spiegelberg 2011-01-04 00:33:48 +00:00
parent 384f4c93dd
commit b99c65fa13
1 changed files with 13 additions and 1 deletions

View File

@ -51,7 +51,19 @@ public class Pair<T1, T2> implements Serializable
this.first = a;
this.second = b;
}
/**
* Constructs a new pair, inferring the type via the passed arguments
* @param <T1> type for first
* @param <T2> type for second
* @param a first element
* @param b second element
* @return a new pair containing the passed arguments
*/
public static <T1,T2> Pair<T1,T2> newPair(T1 a, T2 b) {
return new Pair<T1,T2>(a, b);
}
/**
* Replace the first element of the pair.
* @param a operand