All Downloads are FREE. Search and download functionalities are using the official Maven repository.

vertx.effect.exp.Triple Maven / Gradle / Ivy

There is a newer version: 5.0.0
Show newest version
package vertx.effect.exp;

import io.vavr.Tuple3;
import vertx.effect.Val;
import vertx.effect.core.AbstractVal;

import static java.util.Objects.requireNonNull;

public abstract class Triple extends AbstractVal> {

    public static  Triple parallel(final Val _1,
                                                     final Val _2,
                                                     final Val _3) {
        return new ParallelTriple<>(requireNonNull(_1),
                                    requireNonNull(_2),
                                    requireNonNull(_3)
        );
    }

    public static  Triple sequential(final Val _1,
                                                       final Val _2,
                                                       final Val _3) {
        return new SequentialTriple(requireNonNull(_1),
                                             requireNonNull(_2),
                                             requireNonNull(_3)
        );
    }

    public abstract Val _1();

    public abstract Val _2();

    public abstract Val _3();

    public static  Val race(final Triple triple) {
        if (triple == null)
            return Cons.failure(new IllegalArgumentException("Triple.race: pair is null"));
        return ListExp.parallel(triple._1(),
                                triple._2(),
                                triple._3()
                               )
                      .race();
    }


}