Record Class Tuple3<A,B,C>

java.lang.Object
java.lang.Record
dmx.fun.Tuple3<A,B,C>
Type Parameters:
A - the type of the first element
B - the type of the second element
C - the type of the third element
Record Components:
_1 - the first element
_2 - the second element
_3 - the third element

@NullMarked public record Tuple3<A,B,C>(A _1, B _2, C _3) extends Record
An immutable triple holding three values of potentially different types.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Tuple3(A _1, B _2, C _3)
    Validates that none of the elements are null.
  • Method Summary

    Modifier and Type
    Method
    Description
    _1()
    Returns the value of the _1 record component.
    _2()
    Returns the value of the _2 record component.
    _3()
    Returns the value of the _3 record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    <R> R
    map(TriFunction<? super A, ? super B, ? super C, ? extends R> f)
    Collapses this triple into a single value by applying f to all three elements.
    <R> Tuple3<R,B,C>
    mapFirst(Function<? super A, ? extends R> f)
    Returns a new tuple with f applied to the first element; the other elements are unchanged.
    <R> Tuple3<A,R,C>
    mapSecond(Function<? super B, ? extends R> f)
    Returns a new tuple with f applied to the second element; the other elements are unchanged.
    <R> Tuple3<A,B,R>
    mapThird(Function<? super C, ? extends R> f)
    Returns a new tuple with f applied to the third element; the other elements are unchanged.
    static <A,B,C> Tuple3<A,B,C>
    of(A a, B b, C c)
    Creates a new Tuple3 with the given elements.
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

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

    • Tuple3

      public Tuple3(A _1, B _2, C _3)
      Validates that none of the elements are null.
  • Method Details

    • of

      public static <A,B,C> Tuple3<A,B,C> of(A a, B b, C c)
      Creates a new Tuple3 with the given elements.
      Type Parameters:
      A - the type of the first element
      B - the type of the second element
      C - the type of the third element
      Parameters:
      a - the first element
      b - the second element
      c - the third element
      Returns:
      a new Tuple3 containing the three values
    • mapFirst

      public <R> Tuple3<R,B,C> mapFirst(Function<? super A, ? extends R> f)
      Returns a new tuple with f applied to the first element; the other elements are unchanged.
      Type Parameters:
      R - the type of the new first element
      Parameters:
      f - the mapping function
      Returns:
      a new Tuple3 with the transformed first element
    • mapSecond

      public <R> Tuple3<A,R,C> mapSecond(Function<? super B, ? extends R> f)
      Returns a new tuple with f applied to the second element; the other elements are unchanged.
      Type Parameters:
      R - the type of the new second element
      Parameters:
      f - the mapping function
      Returns:
      a new Tuple3 with the transformed second element
    • mapThird

      public <R> Tuple3<A,B,R> mapThird(Function<? super C, ? extends R> f)
      Returns a new tuple with f applied to the third element; the other elements are unchanged.
      Type Parameters:
      R - the type of the new third element
      Parameters:
      f - the mapping function
      Returns:
      a new Tuple3 with the transformed third element
    • map

      public <R> R map(TriFunction<? super A, ? super B, ? super C, ? extends R> f)
      Collapses this triple into a single value by applying f to all three elements.
      Type Parameters:
      R - the type of the result
      Parameters:
      f - the combining function
      Returns:
      the non-null result of applying f to _1, _2, and _3
    • 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.
    • _1

      public A _1()
      Returns the value of the _1 record component.
      Returns:
      the value of the _1 record component
    • _2

      public B _2()
      Returns the value of the _2 record component.
      Returns:
      the value of the _2 record component
    • _3

      public C _3()
      Returns the value of the _3 record component.
      Returns:
      the value of the _3 record component