Class Pair<A,​B>

  • All Implemented Interfaces:
    Serializable

    public class Pair<A,​B>
    extends Object
    implements Serializable
    A tuple of two elements.

    Inspired by: https://github.com/javatuples/javatuples/blob/master/src/main/java/org/javatuples/Pair.java

    See Also:
    Serialized Form
    • Method Detail

      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • first

        public A first()
        Returns:
        the first element
      • second

        public B second()
        Returns:
        the second element
      • of

        public static <A,​B> Pair<A,​B> of​(A first,
                                                     B second)

        Obtains a tuple of two elements inferring the generic types.

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

        Type Parameters:
        A - the first element type
        B - the second element type
        Parameters:
        first - the first element, may be null
        second - the second element, may be null
        Returns:
        a pair formed from the two parameters, not null