Class Pair<P,​K>


  • public final class Pair<P,​K>
    extends java.lang.Object
    2-tuple utility object. The elements of the 2-tuple might be null.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      P first  
      K second  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean areBothNull()  
      boolean equals​(java.lang.Object other)
      Checks the two objects for equality by delegating to their respective equals() methods.
      int hashCode()
      Compute a hash code using the hash codes of the underlying objects.
      boolean isEitherNull()  
      static <P,​K>
      Pair<P,​K>
      of​(P first, K second)
      Constructor for a Pair.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • first

        public final P first
      • second

        public final K second
    • Method Detail

      • of

        public static <P,​K> Pair<P,​K> of​(P first,
                                                     K second)
        Constructor for a Pair.
        Parameters:
        first - the first object in the Pair
        second - the second object in the pair
      • areBothNull

        public boolean areBothNull()
        Returns:
        whether both elements of this 2-tuple are null.
      • isEitherNull

        public boolean isEitherNull()
        Returns:
        whether any of the two elements of this 2-tuple are null.
      • hashCode

        public int hashCode()
        Compute a hash code using the hash codes of the underlying objects.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        a hashcode of the Pair
      • equals

        public boolean equals​(java.lang.Object other)
        Checks the two objects for equality by delegating to their respective equals() methods.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        other - the Pair to which this one is to be checked for equality
        Returns:
        true if the underlying objects of the Pair are both considered equals()
      • toString

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