Class Pair<T1,​T2>

  • Type Parameters:
    T1 -
    T2 -
    All Implemented Interfaces:
    java.io.Serializable

    public class Pair<T1,​T2>
    extends java.lang.Object
    implements java.io.Serializable
    A generic class for pairs. Copied from org.apache.hadoop.hbase.util.Pair
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected T1 left  
      protected T2 right  
    • Constructor Summary

      Constructors 
      Constructor Description
      Pair()
      Default constructor.
      Pair​(T1 a, T2 b)
      Constructor
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object other)  
      T1 getKey()  
      T1 getLeft()
      Return the left element stored in the pair.
      T2 getRight()
      Return the right element stored in the pair.
      T2 getValue()  
      int hashCode()  
      static <T1,​T2>
      Pair<T1,​T2>
      newPair​(T1 a, T2 b)
      Constructs a new pair, inferring the type via the passed arguments
      void setFirst​(T1 a)
      Replace the left element of the pair.
      void setSecond​(T2 b)
      Replace the right element of the pair.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • left

        protected T1 left
      • right

        protected T2 right
    • Constructor Detail

      • Pair

        public Pair()
        Default constructor.
      • Pair

        public Pair​(T1 a,
                    T2 b)
        Constructor
        Parameters:
        a - operand
        b - operand
    • Method Detail

      • newPair

        public static <T1,​T2> Pair<T1,​T2> newPair​(T1 a,
                                                              T2 b)
        Constructs a new pair, inferring the type via the passed arguments
        Type Parameters:
        T1 - type for left
        T2 - type for right
        Parameters:
        a - left element
        b - right element
        Returns:
        a new pair containing the passed arguments
      • getLeft

        public T1 getLeft()
        Return the left element stored in the pair.
        Returns:
        T1
      • getKey

        public T1 getKey()
      • setFirst

        public void setFirst​(T1 a)
        Replace the left element of the pair.
        Parameters:
        a - operand
      • getRight

        public T2 getRight()
        Return the right element stored in the pair.
        Returns:
        T2
      • getValue

        public T2 getValue()
      • setSecond

        public void setSecond​(T2 b)
        Replace the right element of the pair.
        Parameters:
        b - operand
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object