Record Class Tuple2<T,U>

java.lang.Object
java.lang.Record
mastermind.utils.Tuple2<T,U>
Type Parameters:
T - the type of the first element
U - the type of the second element
Record Components:
first - the first element
second - the second element

public record Tuple2<T,U>(T first, U second) extends Record
Represents a tuple of two elements.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Tuple2(T first, U second)
    Creates an instance of a Tuple2 record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Compares this Tuple2 object with the specified object for equality.
    Returns the value of the first record component.
    final int
    Returns a hash code value for this object.
    Returns the value of the second record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Tuple2

      public Tuple2(T first, U second)
      Creates an instance of a Tuple2 record class.
      Parameters:
      first - the value for the first record component
      second - the value for the second record component
  • Method Details

    • equals

      public boolean equals(Object obj)
      Compares this Tuple2 object with the specified object for equality.
      Specified by:
      equals in class Record
      Parameters:
      obj - the object to be compared for equality with this instance
      Returns:
      true if the specified object is equal to this tuple, false otherwise
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • first

      public T first()
      Returns the value of the first record component.
      Returns:
      the value of the first record component
    • second

      public U second()
      Returns the value of the second record component.
      Returns:
      the value of the second record component