T1 - The type of the first non-null value held by this tupleT2 - The type of the second non-null value held by this tuplepublic class Tuple2<T1,T2>
extends java.lang.Object
implements java.lang.Iterable<java.lang.Object>, java.io.Serializable
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(@Nullable java.lang.Object o) |
@Nullable java.lang.Object |
get(int index)
Get the object at the given index.
|
T1 |
getT1()
Type-safe way to get the first object of this
Tuples. |
T2 |
getT2()
Type-safe way to get the second object of this
Tuples. |
int |
hashCode() |
java.util.Iterator<java.lang.Object> |
iterator()
Return an immutable
Iterator<Object> around
the content of this Tuple. |
<R> Tuple2<R,T2> |
mapT1(java.util.function.Function<T1,R> mapper)
Map the left-hand part (T1) of this
Tuple2 into a different value and type,
keeping the right-hand part (T2). |
<R> Tuple2<T1,R> |
mapT2(java.util.function.Function<T2,R> mapper)
Map the right-hand part (T2) of this
Tuple2 into a different value and type,
keeping the left-hand part (T1). |
int |
size()
Return the number of elements in this Tuples.
|
java.lang.Object[] |
toArray()
Turn this
Tuple into a plain Object[]. |
java.util.List<java.lang.Object> |
toList()
Turn this
Tuple into a List<Object>. |
java.lang.String |
toString()
A Tuple String representation is the comma separated list of values, enclosed
in square brackets.
|
public T1 getT1()
Tuples.public T2 getT2()
Tuples.public <R> Tuple2<R,T2> mapT1(java.util.function.Function<T1,R> mapper)
Tuple2 into a different value and type,
keeping the right-hand part (T2).R - the new type for the left-hand partmapper - the mapping Function for the left-hand partTuple2 with a different left (T1) valuepublic <R> Tuple2<T1,R> mapT2(java.util.function.Function<T2,R> mapper)
Tuple2 into a different value and type,
keeping the left-hand part (T1).R - the new type for the right-hand partmapper - the mapping Function for the right-hand partTuple2 with a different right (T2) valuepublic @Nullable java.lang.Object get(int index)
index - The index of the object to retrieve. Starts at 0.public java.util.List<java.lang.Object> toList()
Tuple into a List<Object>.
The list isn't tied to this Tuple but is a copy with limited
mutability (add and remove are not supported, but set is).List<Object>.public java.lang.Object[] toArray()
Tuple into a plain Object[].
The array isn't tied to this Tuple but is a copy.Object[].public java.util.Iterator<java.lang.Object> iterator()
Iterator<Object> around
the content of this Tuple.iterator in interface java.lang.Iterable<java.lang.Object>Iterator over the elements in this Tuple.Iterator is always tied to its Iterable source by
definition, the iterator cannot be mutable without the iterable also being mutable.
Since Tuples are immutable, so is the Iterator
returned by this method.public boolean equals(@Nullable java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic int size()
public final java.lang.String toString()
toString in class java.lang.Object