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

      Constructors 
      Constructor Description
      Pair​(F first, S second)
      Constructor for a pair.
    • 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 and obj.
      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.
      • Methods inherited from class java.lang.Object

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

      • 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 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 and obj.
        Overrides:
        equals in class java.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 class java.lang.Object
        Returns:
        hash value.
      • toString

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