Record Class Tuple<V1,V2>

java.lang.Object
java.lang.Record
org.jgroups.util.Tuple<V1,V2>
Type Parameters:
V1 - V1
V2 - V2
Record Components:
val1 - val1
val2 - val2

public record Tuple<V1,V2>(V1 val1, V2 val2) extends Record
Holds 2 values, useful when we have a map with a key, but more than 1 value and we don't want to create a separate holder object for the values, and don't want to pass the values as a list or array.
Author:
Bela Ban
  • Constructor Summary

    Constructors
    Constructor
    Description
    Tuple(V1 val1, V2 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.
    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 Object

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

    • Tuple

      public Tuple(V1 val1, V2 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

    • toString

      public 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 V1 val1()
      Returns the value of the val1 record component.
      Returns:
      the value of the val1 record component
    • val2

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