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

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

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

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

import static java.util.Objects.requireNonNull;

public abstract class Quadruple extends AbstractVal> {

    public static  Quadruple parallel(final Val _1,
                                                              final Val _2,
                                                              final Val _3,
                                                              final Val _4) {
        return new ParallelQuadruple<>(requireNonNull(_1),
                                       requireNonNull(_2),
                                       requireNonNull(_3),
                                       requireNonNull(_4)
        );
    }

    public static  Quadruple sequential(final Val _1,
                                                                final Val _2,
                                                                final Val _3,
                                                                final Val _4) {
        return new SequentialQuadruple<>(requireNonNull(_1),
                                         requireNonNull(_2),
                                         requireNonNull(_3),
                                         requireNonNull(_4)
        );
    }

    public abstract Val _1();

    public abstract Val _2();

    public abstract Val _3();

    public abstract Val _4();

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


}