Class Tuple2<V1,V2>

java.lang.Object
io.permazen.tuple.Tuple2<V1,V2>
Type Parameters:
V1 - first value type
V2 - second value type
All Implemented Interfaces:
Has1<V1>, Has2<V1,V2>, Tuple

public class Tuple2<V1,V2> extends Object
A tuple of two values.

Instances are immutable.

  • Constructor Details

    • Tuple2

      public Tuple2(V1 v1, V2 v2)
      Constructor.
      Parameters:
      v1 - the first value
      v2 - the second value
  • Method Details

    • getValue2

      public V2 getValue2()
      Description copied from interface: Has2
      Get the second value.
      Specified by:
      getValue2 in interface Has2<V1,V2>
      Returns:
      second value in this tuple
    • getSize

      public int getSize()
      Description copied from interface: Tuple
      Get the number of values in this tuple.
      Specified by:
      getSize in interface Tuple
      Returns:
      the size of this tuple
    • asList

      public List<Object> asList()
      Description copied from interface: Tuple
      View this instance as a list.
      Specified by:
      asList in interface Tuple
      Returns:
      unmodifiable List view of this tuple
    • hashCode

      public int hashCode()
      Description copied from interface: Tuple
      Compute hash code.

      The hash code of a tuple is the exclusive-OR of the hash codes of the individual values (using zero for null values).

      Specified by:
      hashCode in interface Tuple
    • getValue1

      public V1 getValue1()
      Description copied from interface: Has1
      Get the first value.
      Specified by:
      getValue1 in interface Has1<V1>
      Returns:
      first value in this tuple
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object obj)
      Description copied from interface: Tuple
      Compare for equality.

      Tuples are equal if they have the same size and the corresponding individual values are equal (or null).

      Specified by:
      equals in interface Tuple
      Overrides:
      equals in class Object