Package reactor.util.function
Class Tuple2<T1,T2>
java.lang.Object
reactor.util.function.Tuple2<T1,T2>
- Type Parameters:
T1- The type of the first non-null value held by this tupleT2- The type of the second non-null value held by this tuple
- All Implemented Interfaces:
Serializable,Iterable<Object>
- Direct Known Subclasses:
Tuple3
A tuple that holds two non-null values.
- Author:
- Jon Brisbin, Stephane Maldini
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleanget(int index) Get the object at the given index.getT1()Type-safe way to get the first object of thisTuples.getT2()Type-safe way to get the second object of thisTuples.inthashCode()iterator()Return an immutableIterator<Object>around the content of thisTuple.Map the left-hand part (T1) of thisTuple2into a different value and type, keeping the right-hand part (T2).Map the right-hand part (T2) of thisTuple2into a different value and type, keeping the left-hand part (T1).intsize()Return the number of elements in this Tuples.Object[]toArray()Turn thisTupleinto a plainObject[].toList()Turn thisTupleinto aList<Object>.final StringtoString()A Tuple String representation is the comma separated list of values, enclosed in square brackets.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
getT1
Type-safe way to get the first object of thisTuples.- Returns:
- The first object
-
getT2
Type-safe way to get the second object of thisTuples.- Returns:
- The second object
-
mapT1
Map the left-hand part (T1) of thisTuple2into a different value and type, keeping the right-hand part (T2). -
mapT2
Map the right-hand part (T2) of thisTuple2into a different value and type, keeping the left-hand part (T1). -
get
Get the object at the given index.- Parameters:
index- The index of the object to retrieve. Starts at 0.- Returns:
- The object or null if out of bounds.
-
toList
Turn thisTupleinto aList<Object>. The list isn't tied to this Tuple but is a copy with limited mutability (addandremoveare not supported, butsetis).- Returns:
- A copy of the tuple as a new
List<Object>.
-
toArray
Turn thisTupleinto a plainObject[]. The array isn't tied to this Tuple but is a copy.- Returns:
- A copy of the tuple as a new
Object[].
-
iterator
Return an immutableIterator<Object>around the content of thisTuple.- Specified by:
iteratorin interfaceIterable<T1>- Returns:
- An unmodifiable
Iteratorover the elements in this Tuple. - Implementation Note:
- As an
Iteratoris always tied to itsIterablesource by definition, the iterator cannot be mutable without the iterable also being mutable. SinceTuplesare immutable, so is theIteratorreturned by this method.
-
equals
-
hashCode
public int hashCode() -
size
public int size()Return the number of elements in this Tuples.- Returns:
- The size of this Tuples.
-
toString
A Tuple String representation is the comma separated list of values, enclosed in square brackets.
-