Package com.linkedin.alpini.base.misc
Class Pair<F,S>
- java.lang.Object
-
- com.linkedin.alpini.base.misc.Pair<F,S>
-
- Direct Known Subclasses:
ImmutableMapEntry
public class Pair<F,S> extends java.lang.ObjectA simple container for a pair of (2) values. Adapted from Jemiah's code in com.linkedin.util. This class lets us hold a pair of elements
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <P extends Pair<F,S>,F,S>
P[]array(P... array)Return an array of Pair.booleanequals(java.lang.Object obj)Test for equality between this andobj.FgetFirst()Return the first value.SgetSecond()Return the second value.inthashCode()Compute a hash value for the Pair.static <F,S>
Pair<F,S>make(F first, S second)Make a Pair.java.lang.StringtoString()Return a string representation of the Pair.
-
-
-
Constructor Detail
-
Pair
public Pair(F first, S second)
Constructor for a pair. A simpler alternative is to usemake(Object, Object)instead.- Parameters:
first- First value.second- Second value.
-
-
Method Detail
-
make
public static <F,S> Pair<F,S> make(F first, S second)
Make a Pair.- Type Parameters:
F- Type of first argument, usually inferred automatically.S- Type of seconnd argument, usually inferred automatically.- Parameters:
first- First value.second- Second value.- Returns:
- newly constructed Pair instance.
-
array
@SafeVarargs public static <P extends Pair<F,S>,F,S> P[] array(P... array)
Return an array of Pair.- Type Parameters:
F- Type of first argument, usually inferred automatically.S- Type of first argument, usually inferred automatically.- Parameters:
array- Comma seperated list of Pair objects.- Returns:
- array of Pair objects.
-
getFirst
public final F getFirst()
Return the first value.- Returns:
- first value.
-
getSecond
public final S getSecond()
Return the second value.- Returns:
- second value.
-
equals
public boolean equals(java.lang.Object obj)
Test for equality between this andobj.- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- Value to test against.- Returns:
trueif equals.
-
hashCode
public int hashCode()
Compute a hash value for the Pair.- Overrides:
hashCodein classjava.lang.Object- Returns:
- hash value.
-
toString
public java.lang.String toString()
Return a string representation of the Pair.- Overrides:
toStringin classjava.lang.Object- Returns:
- string.
-
-