javatuplesproject-reactor

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


Created this question and answer to help others with quick lookup of how to create a Reactor Tuple, such as reactor.util.function.Tuple2<T1,T2>

I couldn't find any example constructor on the Javadoc for Tuple2 so had to do some more digging.


Solution

  • 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