AlexanderTheGrape
AlexanderTheGrape

Reputation: 65

How to create a Tuple2, Tuple3 etc in Java Reactor?

How do you create a Reactor Tuple, such as reactor.util.function.Tuple2<T1,T2> ?

Upvotes: 0

Views: 571

Answers (2)

AlexanderTheGrape
AlexanderTheGrape

Reputation: 65

Use reactor.util.function.Tuples.of(T1 t1, T2 t2)

Note that it uses the Tuples class.

Method signature:

static <T1,T2> Tuple2<T1,T2> of(T1 t1, T2 t2)

More methods and constructors available in the Javadoc

Upvotes: 2

talex
talex

Reputation: 20544

There are plenty of tuple libraries.

One of them is Java SDK, which have Map.Entry. You can create it with Map.entry().

There are also org.apache.commons.lang3.tuple.Pair from

<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-lang3</artifactId>
</dependency>

It use Pair.of() method.

There are plenty of others. Most of them use similar approach.

To answer your specific question: There is reactor.util.function.Tuples.of() method.

Upvotes: 0

Related Questions