Record Class Tuple2<A,B>
java.lang.Object
java.lang.Record
dmx.fun.Tuple2<A,B>
- Type Parameters:
A- the type of the first elementB- the type of the second element- Record Components:
_1- the first element_2- the second element
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription_1()Returns the value of the_1record component._2()Returns the value of the_2record component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.<R> Rmap(BiFunction<? super A, ? super B, ? extends R> f) Collapses this pair into a single value by applyingfto both elements.Returns a new tuple withfapplied to the first element; the second element is unchanged.Returns a new tuple withfapplied to the second element; the first element is unchanged.static <A,B> Tuple2 <A, B> of(A a, B b) Creates a newTuple2with the given elements.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Tuple2
-
-
Method Details
-
of
Creates a newTuple2with the given elements.- Type Parameters:
A- the type of the first elementB- the type of the second element- Parameters:
a- the first elementb- the second element- Returns:
- a new
Tuple2containing the two values
-
mapFirst
Returns a new tuple withfapplied to the first element; the second element is unchanged.- Type Parameters:
R- the type of the new first element- Parameters:
f- the mapping function; must not benulland must not returnnull- Returns:
- a new
Tuple2with the transformed first element - Throws:
NullPointerException- iffisnullor returnsnull
-
mapSecond
Returns a new tuple withfapplied to the second element; the first element is unchanged.- Type Parameters:
R- the type of the new second element- Parameters:
f- the mapping function; must not benulland must not returnnull- Returns:
- a new
Tuple2with the transformed second element - Throws:
NullPointerException- iffisnullor returnsnull
-
map
Collapses this pair into a single value by applyingfto both elements.- Type Parameters:
R- the type of the result- Parameters:
f- the combining function- Returns:
- the non-null result of applying
fto_1and_2
-
toString
-
hashCode
-
equals
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 withObjects::equals(Object,Object). -
_1
-
_2
-