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.Object
A 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.boolean
equals(java.lang.Object obj)
Test for equality between this andobj
.F
getFirst()
Return the first value.S
getSecond()
Return the second value.int
hashCode()
Compute a hash value for the Pair.static <F,S>
Pair<F,S>make(F first, S second)
Make a Pair.java.lang.String
toString()
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:
equals
in classjava.lang.Object
- Parameters:
obj
- Value to test against.- Returns:
true
if equals.
-
hashCode
public int hashCode()
Compute a hash value for the Pair.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- hash value.
-
toString
public java.lang.String toString()
Return a string representation of the Pair.- Overrides:
toString
in classjava.lang.Object
- Returns:
- string.
-
-