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 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
  • Constructor Summary

    Constructors
    Constructor
    Description
    Pair(F first, S second)
    Constructor for a pair.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <P extends Pair<F, S>, F, S>
    P[]
    array(P... array)
    Return an array of Pair.
    boolean
    Test for equality between this and obj.
    final F
    Return the first value.
    final S
    Return the second value.
    int
    Compute a hash value for the Pair.
    static <F, S> Pair<F,S>
    make(F first, S second)
    Make a Pair.
    Return a string representation of the Pair.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Pair

      public Pair(F first, S second)
      Constructor for a pair. A simpler alternative is to use make(Object, Object) instead.
      Parameters:
      first - First value.
      second - Second value.
  • Method Details

    • 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(Object obj)
      Test for equality between this and obj.
      Overrides:
      equals in class 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 class Object
      Returns:
      hash value.
    • toString

      public String toString()
      Return a string representation of the Pair.
      Overrides:
      toString in class Object
      Returns:
      string.