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 Object implements Iterable<Object>, Serializable
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
Object |
get(int index)
Get the object at the given index.
|
T1 |
getT1()
Type-safe way to get the fist object of this
Tuples . |
T2 |
getT2()
Type-safe way to get the second object of this
Tuples . |
int |
hashCode() |
Iterator<Object> |
iterator()
Return an immutable
Iterator<Object> around
the content of this Tuple . |
<R> Tuple2<R,T2> |
mapT1(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(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.
|
Object[] |
toArray()
Turn this
Tuple into a plain Object[] . |
List<Object> |
toList()
Turn this
Tuple into a List<Object> . |
String |
toString()
A Tuple String representation is the comma separated list of values, enclosed
in square brackets.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
@Nullable public Object get(int index)
index
- The index of the object to retrieve. Starts at 0.public T1 getT1()
Tuples
.public T2 getT2()
Tuples
.public Iterator<Object> iterator()
Iterator<Object>
around
the content of this Tuple
.iterator
in interface Iterable<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 <R> Tuple2<R,T2> mapT1(Function<T1,R> mapper)
Tuple2
into a different value and type,
keeping the right-hand part (T2).public <R> Tuple2<T1,R> mapT2(Function<T2,R> mapper)
Tuple2
into a different value and type,
keeping the left-hand part (T1).public int size()
public Object[] toArray()
Tuple
into a plain Object[]
.
The array isn't tied to this Tuple but is a copy.Object[]
.public List<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>
.