Record Class Tuple<A,B>

java.lang.Object
java.lang.Record
io.vertigo.core.lang.Tuple<A,B>
Type Parameters:
A - Type of first object
B - Type of second object

public record Tuple<A,B>(A val1, B val2) extends Record
Immutable Tuple with 2 objects. Provides a way to group two values of different types in a single object. Useful for methods that need to return multiple values.
Author:
pchretien
  • Constructor Summary

    Constructors
    Constructor
    Description
    Tuple(A val1, B val2)
    Creates an instance of a Tuple record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    static <A, B> Tuple<A,B>
    of(A val1, B val2)
    Creates a Tuple with two objects.
    final String
    Returns a string representation of this record class.
    Returns the value of the val1 record component.
    Returns the value of the val2 record component.

    Methods inherited from class java.lang.Object

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

    • Tuple

      public Tuple(A val1, B val2)
      Creates an instance of a Tuple record class.
      Parameters:
      val1 - the value for the val1 record component
      val2 - the value for the val2 record component
  • Method Details

    • of

      public static <A, B> Tuple<A,B> of(A val1, B val2)
      Creates a Tuple with two objects.
      Type Parameters:
      A - Type of first object
      B - Type of second object
      Parameters:
      val1 - First object
      val2 - Second object
      Returns:
      New Tuple
    • 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
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • val1

      public A val1()
      Returns the value of the val1 record component.
      Returns:
      the value of the val1 record component
    • val2

      public B val2()
      Returns the value of the val2 record component.
      Returns:
      the value of the val2 record component