cyclops.conversion.vavr.FromFunctionalJava Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cyclops-vavr Show documentation
Show all versions of cyclops-vavr Show documentation
Converters and Comprehenders for Javaslang
The newest version!
package cyclops.conversion.vavr;
import io.vavr.Function1;
import io.vavr.Function2;
import io.vavr.Function3;
import io.vavr.Function4;
import io.vavr.Function5;
import io.vavr.Function6;
import io.vavr.Function7;
import io.vavr.Function8;
import io.vavr.Tuple1;
import io.vavr.Tuple2;
import io.vavr.Tuple3;
import io.vavr.Tuple4;
import io.vavr.Tuple5;
import io.vavr.Tuple6;
import io.vavr.Tuple7;
import io.vavr.Tuple8;
import io.vavr.control.Either;
import io.vavr.control.Option;
import fj.F;
import fj.F2;
import fj.F3;
import fj.F4;
import fj.F5;
import fj.F6;
import fj.F7;
import fj.F8;
import fj.P1;
import fj.P2;
import fj.P3;
import fj.P4;
import fj.P5;
import fj.P6;
import fj.P7;
import fj.P8;
public class FromFunctionalJava {
public static Function1 f1(F fn) {
return (t) -> fn.f(t);
}
public static Function2 f2(F2 fn) {
return (t, x) -> fn.f(t, x);
}
public static Function3 f3(F3 fn) {
return (t1, t2, t3) -> fn.f(t1, t2, t3);
}
public static Function4 f4(F4 fn) {
return (t1, t2, t3, t4) -> fn.f(t1, t2, t3, t4);
}
public static Function5 f5(F5 fn) {
return (t1, t2, t3, t4, t5) -> fn.f(t1, t2, t3, t4, t5);
}
public static Function6 f6(
F6 fn) {
return (t1, t2, t3, t4, t5, t6) -> fn.f(t1, t2, t3, t4, t5, t6);
}
public static Function7 f7(
F7 fn) {
return (t1, t2, t3, t4, t5, t6, t7) -> fn.f(t1, t2, t3, t4, t5, t6, t7);
}
public static Function8 f8(
F8 fn) {
return (t1, t2, t3, t4, t5, t6, t7, t8) -> fn.f(t1, t2, t3, t4, t5, t6, t7, t8);
}
public static Option option(fj.data.Option o) {
if (o.isNone())
return Option.none();
return Option.of(o.some());
}
public static Either either(fj.data.Either e) {
if (e.isLeft())
return Either.left(e.left()
.value());
else
return Either.right(e.right()
.value());
}
public static Tuple1 tuple(P1 t) {
return new Tuple1(
t._1());
}
public static Tuple2 tuple(P2 t) {
return new Tuple2(
t._1(), t._2());
}
public static Tuple3 tuple(P3 t) {
return new Tuple3(
t._1(), t._2(), t._3());
}
public static Tuple4 tuple(P4 t) {
return new Tuple4(
t._1(), t._2(), t._3(), t._4());
}
public static Tuple5 tuple(P5 t) {
return new Tuple5(
t._1(), t._2(), t._3(), t._4(), t._5());
}
public static Tuple6 tuple(P6 t) {
return new Tuple6(
t._1(), t._2(), t._3(), t._4(), t._5(), t._6());
}
public static Tuple7 tuple(
P7 t) {
return new Tuple7(
t._1(), t._2(), t._3(), t._4(), t._5(), t._6(), t._7());
}
public static Tuple8 tuple(
P8 t) {
return new Tuple8(
t._1(), t._2(), t._3(), t._4(), t._5(), t._6(), t._7(), t._8());
}
}