Class Pair<A,​B>

  • Type Parameters:
    A - the type of the first value
    B - the type of the second value
    All Implemented Interfaces:
    Serializable

    public class Pair<A,​B>
    extends Object
    implements Serializable
    Pair of two generic values.
    Author:
    Herbert Praehofer
    See Also:
    Serialized Form
    • Field Detail

      • fst

        public final A fst
        The first value.
      • snd

        public final B snd
        The second value.
    • Constructor Detail

      • Pair

        private Pair​(A fst,
                     B snd)
        Private constructor.
        Parameters:
        fst - the first value
        snd - the second value
    • Method Detail

      • of

        public static <A,​B> Pair<A,​B> of​(A fst,
                                                     B snd)
        Creates a pair of two values.
        Type Parameters:
        A - the type of the first value
        B - the type of the second value
        Parameters:
        fst - the first value
        snd - the second value
        Returns:
        the pair of first and second value
      • hashCode

        public int hashCode()
        Computes a hash code from the hash codes of the two values.
        Overrides:
        hashCode in class Object
        Returns:
        the hash code
      • equals

        public boolean equals​(Object obj)
        Compares this pair object and the other object for equality. They are equal if the second object is a pair and the two values are equal.
        Overrides:
        equals in class Object
        Parameters:
        obj - the other object
        Returns:
        true if the second object is a pair and the two values are equal
      • toString

        public String toString()
        Returns a string representation.
        Overrides:
        toString in class Object
        Returns:
        string representation