Top Description Fields Constructors Methods
reactor.util.function

public Class Tuple2<T1, T2>

extends Object
implements Iterable<Object>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.lang.Iterable
Known Direct Subclasses
reactor.util.function.Tuple3
Annotations
@SuppressWarnings:rawtypes
Type Parameters
<T1>
The type of the first non-null value held by this tuple
<T2>
The type of the second non-null value held by this tuple
Imports
java.io.Serializable, java.util.Arrays, .Collections, .Iterator, .List, .Objects, java.util.function.Function, reactor.util.annotation.NonNull, .Nullable

A tuple that holds two non-null values.
Authors
Jon Brisbin, Stephane Maldini

Field Summary

Modifier and TypeField and Description
private static final long
pack-priv final T1
pack-priv final T2

Constructor Summary

AccessConstructor and Description
pack-priv
Tuple2(T1 t1, T2 t2)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public Object

Returns:

The object or null if out of bounds.
get
(int
The index of the object to retrieve. Starts at 0.
index
)

Get the object at the given index.

public T1

Returns:

The first object
getT1
()

Type-safe way to get the first object of this Tuples.

public T2

Returns:

The second object
getT2
()

Type-safe way to get the second object of this Tuples.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public Iterator<Object>

Returns:

An unmodifiable Iterator over the elements in this Tuple.
iterator
()

Implements java.lang.Iterable.iterator.

Return an immutable Iterator<Object> around the content of this Tuple.
public <
the new type for the left-hand part
R
>
Tuple2<R, T2>

Returns:

a new Tuple2 with a different left (T1) value
mapT1
(Function<T1, R>
the mapping Function for the left-hand part
mapper
)

Map the left-hand part (T1) of this Tuple2 into a different value and type, keeping the right-hand part (T2).

public <
the new type for the right-hand part
R
>
Tuple2<T1, R>

Returns:

a new Tuple2 with a different right (T2) value
mapT2
(Function<T2, R>
the mapping Function for the right-hand part
mapper
)

Map the right-hand part (T2) of this Tuple2 into a different value and type, keeping the left-hand part (T1).

public int

Returns:

The size of this Tuples.
size
()

Return the number of elements in this Tuples.

public Object[]

Returns:

A copy of the tuple as a new Object[].
toArray
()

Turn this Tuple into a plain Object[].

public List<Object>

Returns:

A copy of the tuple as a new List<Object>.
toList
()

Turn this Tuple into a List<Object>.

public final String

Returns:

the Tuple String representation
toString
()

Overrides java.lang.Object.toString.

A Tuple String representation is the comma separated list of values, enclosed in square brackets.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID
t1back to summary
pack-priv final T1 t1
Annotations
@NonNull
t2back to summary
pack-priv final T2 t2
Annotations
@NonNull

Constructor Detail

Tuple2back to summary
pack-priv Tuple2(T1 t1, T2 t2)

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getback to summary
public Object get(int index)

Get the object at the given index.

Parameters
index:int

The index of the object to retrieve. Starts at 0.

Returns:Object

The object or null if out of bounds.

Annotations
@Nullable
getT1back to summary
public T1 getT1()

Type-safe way to get the first object of this Tuples.

Returns:T1

The first object

getT2back to summary
public T2 getT2()

Type-safe way to get the second object of this Tuples.

Returns:T2

The second object

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
iteratorback to summary
public Iterator<Object> iterator()

Implements java.lang.Iterable.iterator.

Return an immutable Iterator<Object> around the content of this Tuple.

Implementation Note

As an 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.

Returns:Iterator<Object>

An unmodifiable Iterator over the elements in this Tuple.

Annotations
@Override
mapT1back to summary
public <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).

Parameters
<R>
the new type for the left-hand part
mapper:Function<T1, R>

the mapping Function for the left-hand part

Returns:Tuple2<R, T2>

a new Tuple2 with a different left (T1) value

mapT2back to summary
public <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).

Parameters
<R>
the new type for the right-hand part
mapper:Function<T2, R>

the mapping Function for the right-hand part

Returns:Tuple2<T1, R>

a new Tuple2 with a different right (T2) value

sizeback to summary
public int size()

Return the number of elements in this Tuples.

Returns:int

The size of this Tuples.

toArrayback to summary
public Object[] toArray()

Turn this Tuple into a plain Object[]. The array isn't tied to this Tuple but is a copy.

Returns:Object[]

A copy of the tuple as a new Object[].

toListback to summary
public List<Object> toList()

Turn this 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).

Returns:List<Object>

A copy of the tuple as a new List<Object>.

toStringback to summary
public final String toString()

Overrides java.lang.Object.toString.

A Tuple String representation is the comma separated list of values, enclosed in square brackets.

Returns:String

the Tuple String representation

Annotations
@Override