Class Pair<T1,​T2>

  • All Implemented Interfaces:
    java.util.Map.Entry<T1,​T2>

    public class Pair<T1,​T2>
    extends java.lang.Object
    implements java.util.Map.Entry<T1,​T2>
    An arbitrary pair of objects. Convenient implementation of Map.Entry.
    • Field Detail

      • first

        public T1 first
      • second

        public T2 second
    • Constructor Detail

      • Pair

        public Pair()
      • Pair

        public Pair​(T1 f,
                    T2 s)
    • Method Detail

      • of

        public static <L,​R> Pair<L,​R> of​(L left,
                                                     R right)
        Obtains a mutable pair of two objects inferring the generic types.

        This factory allows the pair to be created using inference to obtain the generic types.

        Type Parameters:
        L - the left element type
        R - the right element type
        Parameters:
        left - the left element, may be null
        right - the right element, may be null
        Returns:
        a pair formed from the two parameters, not null
        Since:
        1.4
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Map.Entry<T1,​T2>
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object object)
        Specified by:
        equals in interface java.util.Map.Entry<T1,​T2>
        Overrides:
        equals in class java.lang.Object
      • toString

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

        public T1 getKey()
        Specified by:
        getKey in interface java.util.Map.Entry<T1,​T2>
      • getValue

        public T2 getValue()
        Specified by:
        getValue in interface java.util.Map.Entry<T1,​T2>
      • setValue

        public T2 setValue​(T2 value)
        Specified by:
        setValue in interface java.util.Map.Entry<T1,​T2>