Interface Product2<_1,_2>

Type Parameters:
_1 - The first element type
_2 - The second element type
All Superinterfaces:
Map.Entry<_1,_2>
All Known Subinterfaces:
Product3<_1,_2,_3>, Product4<_1,_2,_3,_4>, Product5<_1,_2,_3,_4,_5>, Product6<_1,_2,_3,_4,_5,_6>, Product7<_1,_2,_3,_4,_5,_6,_7>, Product8<_1,_2,_3,_4,_5,_6,_7,_8>
All Known Implementing Classes:
Tuple2, Tuple3, Tuple4, Tuple5, Tuple6, Tuple7, Tuple8

public interface Product2<_1,_2> extends Map.Entry<_1,_2>
The minimal shape of the combination of two potentially distinctly typed values, supporting destructuring via explicitly named indexing methods, as well as via a combining function.

For more information, read about products.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    _1()
    Retrieve the first element.
    _2()
    Retrieve the second element.
    default _1
     
    default _2
     
    default <R> R
    into(Fn2<? super _1,? super _2,? extends R> fn)
    Destructure and apply this product to a function accepting the same number of arguments as this product's slots.
    default Product2<_2,_1>
    Rotate the first two slots of this product.
    static <_1, _2> Product2<_1,_2>
    product(_1 _1, _2 _2)
    Static factory method for creating a generic Product2.
    default _2
    setValue(_2 value)
     

    Methods inherited from interface java.util.Map.Entry

    equals, hashCode
  • Method Details

    • _1

      _1 _1()
      Retrieve the first element.
      Returns:
      the first element
    • _2

      _2 _2()
      Retrieve the second element.
      Returns:
      the second element
    • into

      default <R> R into(Fn2<? super _1,? super _2,? extends R> fn)
      Destructure and apply this product to a function accepting the same number of arguments as this product's slots. This can be thought of as a kind of dual to uncurrying a function and applying a product to it.
      Type Parameters:
      R - the return type of the function
      Parameters:
      fn - the function to apply
      Returns:
      the result of applying the destructured product to the function
    • invert

      default Product2<_2,_1> invert()
      Rotate the first two slots of this product.
      Returns:
      the rotated product
    • getKey

      default _1 getKey()
      Specified by:
      getKey in interface Map.Entry<_1,_2>
    • getValue

      default _2 getValue()
      Specified by:
      getValue in interface Map.Entry<_1,_2>
    • setValue

      default _2 setValue(_2 value)
      Specified by:
      setValue in interface Map.Entry<_1,_2>
    • product

      static <_1, _2> Product2<_1,_2> product(_1 _1, _2 _2)
      Static factory method for creating a generic Product2.
      Type Parameters:
      _1 - the first slot type
      _2 - the second slot type
      Parameters:
      _1 - the first slot
      _2 - the second slot
      Returns:
      the Product2